django.core.exceptions.ImproperlyConfigured: Requested setting AUTH_USER_MODEL, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

1,508 views
Skip to first unread message

Tushar Khairnar

unread,
Dec 5, 2018, 7:28:01 AM12/5/18
to Django users
C:\Python\python.exe "D:/Python/django reset framework/secondtestdjrstapi/users/views.py"
Traceback (most recent call last):
  File "D:/Python/django reset framework/secondtestdjrstapi/users/views.py", line 2, in <module>
    from rest_framework.authtoken.models import Token
  File "C:\Python\lib\site-packages\rest_framework\authtoken\models.py", line 11, in <module>
    class Token(models.Model):
  File "C:\Python\lib\site-packages\rest_framework\authtoken\models.py", line 17, in Token
    settings.AUTH_USER_MODEL, related_name='auth_token',
  File "C:\Python\lib\site-packages\django\conf\__init__.py", line 57, in __getattr__
    self._setup(name)
  File "C:\Python\lib\site-packages\django\conf\__init__.py", line 42, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting AUTH_USER_MODEL, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
debug_err.png

Ryan Nowakowski

unread,
Dec 5, 2018, 8:27:22 AM12/5/18
to django...@googlegroups.com
I'm not quite sure what you're trying to do. Are you trying to run views.py?

Sidnei Pereira

unread,
Dec 6, 2018, 10:41:01 AM12/6/18
to Django users
It seems you are trying to execute de `views.py` module directly. As you are running Django you should run it's webserver through `manage.py` so Django you setup everything it is expected and the process starts to listen to port: So:

python manage.py runserver

It will run the server by default in the localhost and port 8000. To test your `view` open the browser and type the correspondent URL (http://localhost:8000/this_view_url/) for that view.

Actually I strongly recommend you to go through the "Getting started with Django" (https://www.djangoproject.com/start/)

*P.S.: Looks like you are using PyCham IDE and there you hit play/run button to start the application but before it needs to be correctly setup. It may vary from professional to community version, but you Basically have to add a run configuration (next to the play button on the top right). In pro version just choose "Django server" on the template's list, usually the default values are good to go. The community one does not have the "Django Server" on the list so choose "Python" and type the runserver command as explained before.

Parker Bernard

unread,
Dec 6, 2018, 12:18:22 PM12/6/18
to django...@googlegroups.com
how do i open my django in my pycharm or python


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f0597428-5b2b-41a3-93cc-1fd326b1f828%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sidnei Pereira

unread,
Dec 7, 2018, 8:57:49 AM12/7/18
to Django users
Reply all
Reply to author
Forward
0 new messages