Code Monkey home page Code Monkey logo

dj4e-samples's Introduction

DJ4E Samples

This is a set of Django projects that provide free sample code to support the www.dj4e.com web site.

You can see some of the samples working at

http://samples.dj4e.com

Setting up a Virtual Environment on the Mac

Install virtualenv, if you use homebrew you can:

brew install virtualenv

Then checkout this repository:

cd ...wherever...
git clone https://github.com/csev/dj4e-samples.git
cd dj4e-samples
virtualenv .venv
source .venv/bin/activate
python --version
pip install -r requirements42.txt

python manage.py migrate
python manage.py createsuperuser --username dj4e-samples
# python manage.py changepassword dj4e-samples
# dj4e_nn_!

Running Locally on the Mac

If you have Django installed on your local computer you can test any of the sample applications by going into the folder and starting the server:

cd dj4e-samples
source .venv/bin/activate   # If needed
python manage.py runserver

And visit http://localhost:8000.

Setting up a Virtual Environment on Python Anywhere

The instructions for setting up a virtual environment on PythonAnywhere in the Linux shell are:

mkvirtualenv django4 --python=/usr/bin/python3.11
pip install django==4.2.3 ## this may take a couple of minutes

To activate the environment type:

workon django4

Then check this out into some folder:

cd ~/django_projects    # Create the folder if needed
git clone https://github.com/csev/dj4e-samples.git
cd dj4e-samples
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser --username dj4e-samples
# python manage.py changepassword dj4e-samples
# dj4e_nn_!
python manage.py runscript gview_load
python manage.py runscript many_load

These samples may be updated from time to time so you might want to get updates using git pull. Also if there are bugs, you are welcome to submit a Pull Request on github.

All of the documentation material is copyright CC-BY 3.0 and the code is copyright MIT by whomever wrote the code or documentation. You are welcome to use this in any way you see fit and paste code from this repo into your applications.

Running on PythonAnywhere

Once you have checked out the code under django_projects, and ran the migrations and load scripts, go under the Web tab, update the config files to point to your new application:

Source code:                /home/--your-account--/django_projects/dj4e-samples
Working Directory:          /home/--your-account--/django_projects/dj4e-samples

Use this as your WGSI configuration file:

import os
import sys

path = os.path.expanduser('~/django_projects/dj4e-samples')
if path not in sys.path:
    sys.path.insert(0, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'dj4e-samples.settings'
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())

You can edit these files and settings in the Web tab to switch between your various projects on PythonAnywhere. Make sure to reload under the Web tab after every file or configuration change.

dj4e-samples's People

Contributors

abdul88dev avatar csev avatar dependabot[bot] avatar f4r6d avatar favour-olumese avatar olivermaerz avatar schekutiev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dj4e-samples's Issues

ModuleNotFoundError: No module named 'tracks'. I pulled the code from Github but I keep getting the error in the "tracks " app that there is no module named "tracks". The folder doesn't even come with a manage.py file. Please any help will be appreciated.

ModuleNotFoundError: No module named 'tracks'. I pulled the code from Github but I keep getting the error in the "tracks " app that there is no module named "tracks". The folder doesn't even come with a manage.py file. Please any help will be appreciated.

pics app | return from method clean() in CreateForm

Hi, i am new here. So be kind to me if I wrote stupidity)
But it's look like you forgot to return clean_data from method clean() in pics/forms.py/CreateForm

according to documentation:

The clean() method on a Field subclass is responsible for running to_python(), validate(), and run_validators() in the correct order and propagating their errors. If, at any time, any of the methods raise ValidationError, the validation stops and that error is raised. This method returns the clean data, which is then inserted into the cleaned_data dictionary of the form.

` Now it's:

def clean(self):
    cleaned_data = super().clean()
    pic = cleaned_data.get('picture')
    if pic is None:
        return
    if len(pic) > self.max_upload_limit:
        self.add_error('picture', "File must be < "+self.max_upload_limit_text+" bytes")`

Also we can see that super().clean() return clean_data

` May be it should be like this:

def clean(self):
    cleaned_data = super().clean()
    pic = cleaned_data.get('picture')
    if pic is None:
        return clean_data
    if len(pic) > self.max_upload_limit:
        self.add_error('picture', "File must be < "+self.max_upload_limit_text+" bytes")
    return clean_data`

p.s. may be it should also raise ValidationError after self.add_error(....)? Otherwise how is_valid() will know about error. Or it will take information from self.add_error(....)?

ModuleNotFoundError/ImproperlyConfigured /ImportError

When tried to import models module to views.py, this way I got_ the error of ImproperlyConfigured.

**from django.shortcuts import render
from models import Car

Create your views here.

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')**

This Is the error here below ๐Ÿ‘‡
(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from models import Car
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\models.py", line 4, in
class Car(models.Model):
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\db\models\base.py", line 127, in new
app_config = apps.get_containing_app_config(module)
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\apps\registry.py", line 260, in get_containing_app_config
self.check_apps_ready()
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\apps\registry.py", line 137, in check_apps_ready
settings.INSTALLED_APPS
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\conf_init_.py", line 87, in getattr
self.setup(name)
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\conf_init
.py", line 67, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

I tried another way to import it again this way ๐Ÿ‘‡

**from django.shortcuts import render
from .models import Car

Create your views here.

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')**

This is the error that I got here ( ImportError: attempted relative import with no known parent package)๐Ÿ‘‡

(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from .models import Car
ImportError: attempted relative import with no known parent package

Lastly I tired to import it this way too ๐Ÿ‘‡

**from django.shortcuts import render
from gview.models import Car

Create your views here.

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')**

Here is the error that I got (moduleNotFoundError) ๐Ÿ‘‡

(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from gview.models import Car
ModuleNotFoundError: No module named 'gview'**m .models import Car
ImportError: attempted relative import with no known parent package

Lastly I tired to import it this way too ๐Ÿ‘‡

**from django.shortcuts import render
from gview.models import Car

Create your views here.

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')**

Here is the error that I got (moduleNotFoundError) ๐Ÿ‘‡

(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from gview.models import Car
ModuleNotFoundError: No module named 'gview'

pip install -r requirements.txt fails

This command fails and shows an error for mysqlclient>=1.4.6. It said mysql-config not found.
I resolved this by first installing mysql-config using sudo apt-get install libmysqlclient-dev.
Now it is working.
The issue is solved but I would like to see this as a note on the website!
Thank you.

ModuleNotFoundError/ImproperlyConfigured/ModuleError

When tried to import models module to views.py, this way I got_ the error of ImproperlyConfigured.

*from django.shortcuts import render
from models import Car

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')

This Is the error here below ๐Ÿ‘‡
(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from models import Car
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\models.py", line 4, in
class Car(models.Model):
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\db\models\base.py", line 127, in new
app_config = apps.get_containing_app_config(module)
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\apps\registry.py", line 260, in get_containing_app_config
self.check_apps_ready()
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\apps\registry.py", line 137, in check_apps_ready
settings.INSTALLED_APPS
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\conf_init_.py", line 87, in getattr
self.setup(name)
File "C:\Users\Salam Taofeek\Desktop\django3\lib\site-packages\django\conf_init
.py", line 67, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

I tried another way to import it again this way ๐Ÿ‘‡

*from django.shortcuts import render
from .models import Car

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')

This is the error that I got here ( ImportError: attempted relative import with no known parent package)๐Ÿ‘‡

(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from .models import Car
ImportError: attempted relative import with no known parent package

Lastly I tired to import it this way too ๐Ÿ‘‡

**from django.shortcuts import render
from gview.models import Car

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')

Here is the error that I got (moduleNotFoundError) ๐Ÿ‘‡

(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from gview.models import Car
ModuleNotFoundError: No module named 'gview'**m .models import Car
ImportError: attempted relative import with no known parent package

Lastly I tired to import it this way too ๐Ÿ‘‡

*from django.shortcuts import render
from gview.models import Car

from django.http import HttpResponse

def index(request):
return HttpResponse('Hello, word. You are at the polls index.')

Here is the error that I got (moduleNotFoundError) ๐Ÿ‘‡

(django3) C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls>python views.py
Traceback (most recent call last):
File "C:\Users\Salam Taofeek\Desktop\django3\django_projects\mysite\polls\views.py", line 2, in
from gview.models import Car
ModuleNotFoundError: No module named 'gview'

Please I need quick response to this
Thanks

Warnings from Installing the Sample Code for DJ4E Section of Web Application Technologies and Django

I'm currently taking Coursera's Django for Everyone and repeating the first course Web Application Technologies and Django and having problems with the Installing Django on PythonAnywhere assignment.

From https://www.dj4e.com/assn/dj4e_install.md, in the Installing the Sample Code for DJ4E section:

Initially running python3 manage.py check resulted in 44 issues identified.

Ignoring the message doesn't seem to impact the function, but it's causing confusion for folks based on recent forum posts.

Here is copied text from running the command as instructed (after correctly running the preceding commands):

(django3) 20:18 ~/dj4e-samples (main)$ python3 manage.py check
When you want to use social login, please see dj4e-samples/github_settings-dist.py
Using registration/login.html as the login template
System check identified some issues:

WARNINGS:
autos.Auto: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the AutosConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.autos.Make: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the AutosConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookmany.Author: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookmanyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookmany.Authored: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookmanyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookmany.Book: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookmanyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookone.Book: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookoneConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookone.Instance: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookoneConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookone.Lang: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookoneConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.cats.Breed: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the CatsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.cats.Cat: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the CatsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.chat.Message: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ChatConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.favs.Fav: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the FavsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.favs.Thing: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the FavsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.favsql.Fav: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the FavsqlConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.favsql.Thing: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the FavsqlConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.form.Cat: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the FormConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.forums.Comment: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ForumsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.forums.Forum: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ForumsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.gview.Car: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the GviewConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.gview.Cat: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the GviewConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.gview.Dog: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the GviewConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.gview.Horse: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the GviewConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.many.Course: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ManyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.many.Membership: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ManyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.many.Person: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ManyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.myarts.Article: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the MyartsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.pics.Pic: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the PicsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.rest.Breed: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the RestConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.rest.Cat: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the RestConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.tracks.Album: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TracksConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.tracks.Artist: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TracksConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.tracks.Genre: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TracksConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.tracks.Track: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TracksConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.users.User: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the UsersConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.well.Post: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the WellConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.

System check identified 44 issues (0 silenced).

python manage.py check warning issue with Django3.2 and latest version

When you want to use social login, please see dj4e-samples/github_settings-dist.py
Using registration/login.html as the login template
System check identified some issues:

WARNINGS:
autos.Auto: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the AutosConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
social_django.Nonce: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the PythonSocialAuthConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.
193 'social_core.backends.github.GithubOAuth2',
users.User: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the UsersConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigA
utoField'.
well.Post: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the WellConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAu
toField'.
System check identified 42 issues (0 silenced).

Fix : Add Default primary key field type
If the similar issue exits please make include the following line inside your project setting.py file

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

Reference: https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

Ads Assignment #1: Can't log in

UPDATE:

The following issue was detected using PythonAnywhere. I managed to finish the assignment starting over in a local project and just copying the necessary code from dj4e-samples. However, it'd be interesting to understand why it isn't working in PA.


Hello,

When I try to log in to the ads app it says
ModuleNotFoundError at /accounts/login/
No module named 'oauthlib'

I've done pip install requirements.txt AND requirements4.txt, also I've tried pip install oathlib in my virtual environment but it says i already have it (3.2.2).

I think this is weird because I could log in and log out in the previous assignments (Autos and Cats CRUD)

I'm adding the error log whole error log so you could help figure out what's happening
error_log.txt

third video in 1st lesson points to an erroneous you tube vid

Hi Dr Chuck. completed and loved PY4E, WD4E and WA4E. Now started to play with DJ4E.

I think there is something awry here. In the 1st lesson HyperText Markup Language (HTML), the 3rd video links to a youtube video by Awa Melvine entitled, "Login system using PHP with MYSQL database".

for_issue

dj4e-sample no folder/data found

Hi, i am following your 1 full youtube video which seems to be different than your website videos in terms of commands/folders so do the dj43-sample. when i reached the section to create modules, first i can't find the file manage.py, but i copied it. Now it seems to be totally different since you updated the folders and data inside, such as for users or usermodels. It would be good too if you just provide the older samples to keep me following the 1 youtube video. TIA.
youtube video reference.
Python Django full course | Django Tutorial | Django Web Framework
Regards
Anjum

Error on initial 'python3 manage.py check'

Background

I'm currently taking Coursera's Django for Everyone and repeating the first course "Web Application Technologies and Django" and having problems with the "Installing Django on PythonAnywhere" assignment.

Specific Problem

From https://www.dj4e.com/assn/dj4e_install.md, in the Installing the Sample Code for DJ4E section:

Initially running python3 manage.py check results in 44 issues identified

Here is the text copied from the terminal console. I was on my MacBook Pro which for some reason doesn't have Snagit installed and Grab wasn't working properly so I copied and pasted the text.

(django3) 20:18 ~/dj4e-samples (main)$ python3 manage.py check
When you want to use social login, please see dj4e-samples/github_settings-dist.py
Using registration/login.html as the login template
System check identified some issues:

WARNINGS:
autos.Auto: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the AutosConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.autos.Make: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the AutosConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookmany.Author: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookmanyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookmany.Authored: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookmanyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookmany.Book: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookmanyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookone.Book: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookoneConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookone.Instance: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookoneConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.bookone.Lang: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the BookoneConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.cats.Breed: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the CatsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.cats.Cat: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the CatsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.chat.Message: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ChatConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.favs.Fav: (models.W042) Auto-created primary key used when
not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the FavsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.favs.Thing: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the FavsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.favsql.Fav: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the FavsqlConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.favsql.Thing: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the FavsqlConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.form.Cat: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the FormConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.forums.Comment: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ForumsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.forums.Forum: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ForumsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.gview.Car: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the GviewConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.gview.Cat: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the GviewConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.gview.Dog: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the GviewConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.gview.Horse: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the GviewConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.many.Course: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ManyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.many.Membership: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ManyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.many.Person: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the ManyConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.myarts.Article: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the MyartsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.pics.Pic: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the PicsConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.rest.Breed: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the RestConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.rest.Cat: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the RestConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.tracks.Album: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TracksConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.tracks.Artist: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TracksConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.tracks.Genre: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TracksConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.tracks.Track: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TracksConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.users.User: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the UsersConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.well.Post: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the WellConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.

System check identified 44 issues (0 silenced).

Workaround Solution Identified

The solution was identified and posted in the Coursera forums for "Web Applications Technologies and Django" 5 days ago.

https://www.coursera.org/learn/django-database-web-apps/discussions/weeks/2/threads/vZ632po9EeuGUwo8J7GtBQ

I found a solution, you have to edit the file "settings.py" and add the following line "DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'"
This file is in the directory: ~/dj4e-samples/dj4e-samples

Here is the image posted in the forums.

fixed

After I'd applied the workaround fix

(django3) 20:22 ~/dj4e-samples (main)$ python3 manage.py check
When you want to use social login, please see dj4e-samples/github_settings-dist.py
Using registration/login.html as the login template
System check identified no issues (0 silenced).
(django3) 20:23 ~/dj4e-samples (main)$

No manage.py file in Tracks folder

Hello Doc Charles, I found Issue during your walkthrough on Youtube in mark 5:03:xx, that there no manage.py files on tracks folder on dj4e-samples. If there has been an update I also cannot find update message, if there was any.

Add .gitattributes to disable EOL conversion

I would like to request the addition of a .gitattributes file to the root of the repo with the following content:

* text eol=lf

This will prevent all files showing up with uncomitted changes when cloning in a devcontainer in vscode.

Github social login

For github social login, add the following 2 lines in settings.py for https to work.

SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
SECURE_SSL_REDIRECT = True

forum app | Doubled tables with the same purpose

In the forums app, if we take a look at the models.py module, one can see there two models: Forum and Comment.
In the Forum model defined 'comments' ManyToMany field. And in the Comment a 'forum' ForeignKey field.

According to Django Docs, a ForeignKey to a model (in our case: Forum) auto-generates the reverse-access-manager (with the name: _set ).
Docs: https://docs.djangoproject.com/en/3.2/topics/db/queries/#following-relationships-backward
(It exists also in the m2m field)

Its actually a table that Django generates for us. In our case: 'comment_set'.
We can see that exist two tables with the same purpose ('comment_set' and 'comment'), so we basically create a situation with redundant table.

Image here: https://github.com/LiorA1/Django/blob/main/dj4e-samples/forums/DJ4ESpecialization.png
Fix Suggestion here: https://github.com/LiorA1/Django/blob/main/dj4e-samples/forums/models.py

Thanks

P.S: The same issue exists in the favs App.
P.S 2: For Non C.S Grads, it maybe be beneficial to see it explicitly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.