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. Em quarta-feira, 5 de dezembro de 2018 10:28:01 UTC-2, Tushar Khairnar escreveu: > > 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. > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@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.