18đź‘Ť
From django docs:
A Django settings file contains all the configuration of your Django installation.
When you use Django, you have to tell it which settings you’re using.
Do this by using an environment variable,DJANGO_SETTINGS_MODULE
.The value of
DJANGO_SETTINGS_MODULE
should be in Python path syntax,
e.g.mysite.settings
. Note that the settings module should be on the
Python import search path.
And
ROOT_URLCONF
Default: Not defined
A string representing the full Python import path to your root
URLconf. For example: “mydjangoapps.urls”. Can be overridden on a
per-request basis by setting the attribute urlconf on the incoming
HttpRequest object. See How Django processes a request for details.
7đź‘Ť
If you are using multiple settings files, be sure to import the base settings in all the other settings files. This was how I got this error.
- [Django]-Django Passing data between views
- [Django]-Django REST Framework viewset per-action permissions
- [Django]-How to resolve "iterator should return strings, not bytes"
5đź‘Ť
If you’re working on a Django project, the root of your project(ROOT_URLCONF=
variable) isn’t defined in your settings.py
file, or at least it isn’t defined properly.
If you don’t have a settings.py
file, this block of code should fix the issue:
from django.conf import settings
settings.configure(
# ...
ROOT_URLCONF=__name__,
# ...
),
)
What that does is specify the root of your project runserver
knows where to find your project.
If do have a settings.py
file, then find that variable and add __name__
to it.
- [Django]-Python Asyncio in Django View
- [Django]-ImageField overwrite image file with same name
- [Django]-How do I use a dictionary to update fields in Django models?
0đź‘Ť
Importing project settings directly can cause this to happen:
from config import settings # bad
from django.conf import settings # good
- [Django]-Cancel an already executing task with Celery?
- [Django]-How to make two django projects share the same database
- [Django]-Creating multiple objects with one request in Django and Django Rest Framework