csev / dj4e-samples Goto Github PK
View Code? Open in Web Editor NEWDjango For Everybody Sample Code
Home Page: https://samples.dj4e.com/
License: MIT License
Django For Everybody Sample Code
Home Page: https://samples.dj4e.com/
License: MIT License
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
*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.
*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
**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
*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
I have followed everything as mentioned in https://www.dj4e.com/assn/dj4e_github.md but while executing the following command it is throwing error as " remote: Support for password authentication was removed on August 13, 2021."
git push -u origin main
(enter id and password for git)
Here is the error screenshot:
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 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).
The solution was identified and posted in the Coursera forums for "Web Applications Technologies and Django" 5 days ago.
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.
(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)$
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).
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
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
I have a bunch of issues that the color is yellow.
In the favs app -
The views 'AddFavoriteView' and 'DeleteFavoriteView', use in the 'csrf_exempt' decorator, because we want to allow non-secure access, but I found a way to use csrf token for them.
As can you see here:
views.py: https://github.com/LiorA1/Django/blob/main/dj4e-samples/favs/views.py#L79
I Solved it, by adding 'csrf_token' in the 'list.html' template:
https://github.com/LiorA1/Django/blob/main/dj4e-samples/favs/templates/favs/list.html#L68
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.
For Autos CRUD https://samples.dj4e.com/accounts/login/?next=/autos/
on https://samples.dj4e.com/
The provided log in details don't work for me
"You might need an account and password to log in for certain features. You might try this:
Username: dj4e-samples
Password: dj4e_nn_! "
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.
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(....)?
**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.
**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
**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
**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'
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.
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
Reference: https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
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.
I'm following your dj4e and there is not manage.py for the project
In the myarts/views.py module we can implement 'form_valid', in other manner, without to do a double 'save()' calls.
Implementation suggestion : https://github.com/LiorA1/Django/blob/main/dj4e-samples/myarts/owner.py#L23
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.