Django runserver syntax error - python

I have problem with running Django tutorial.
I'm new with command-line stuff but I've really searched for my issue and try everything before I post this.
I've tried tutorial with pools application and I've run 'runserver' before and it worked at beginning (Django default page). When I added urls.py (just like in tutorial) it wasn't worked anymore.
I've figired out the problem was different versions of Python (2.7, 3.1, 3.5), so I uninstall all of them and install only the Python 3.5.
There were some minor problems with permission but I've runned terminal as administrator and seemed to be ok. But now I cannot do 'runserver' anymore.
When I type:
C:\Users\urszulka\PycharmProjects\DJ\mysite>python manage.py runserver
I've got:
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x039A5858>
Traceback (most recent call last):
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\management\base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Files (x86)\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Program Files (x86)\Python35-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 658, in exec_module
File "<frozen importlib._bootstrap_external>", line 764, in get_code
File "<frozen importlib._bootstrap_external>", line 724, in source_to_code
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\urszulka\PycharmProjects\DJ\mysite\mysite\urls.py", line 1
pythjo`"""mysite URL Configuration
^
SyntaxError: invalid syntax
Why syntax error? I've done everything like before.
I'll be really pleased with your help.

You have typos in file DJ\mysite\mysite\urls.py. Looks like the line 1 was scrambled because you type something random like pythjo and that's not valid python syntax.

Related

What Python packages am I missing?

I'm trying to get my local Windows 10 PC up and running with my Django application. I'm a novice at Python and Django. My app was written by another developer who's been very helpful and has limited availability. I also want to sort it out myself for learning purposes.
I downloaded my code from Bitbucket and loaded all of the packages in the base.txt and development.txt files onto my Windows 10 PC. I keep getting several errors when trying to run the server.
App is using in the following:
Python 3.61
Django 1.11.3
base.txt file:
boto3==1.4.7
celery==4.1.0
click==6.7
dateutils==0.6.6
Django==1.11.3
django-anymail==0.11.1
django-cors-headers==2.1.0
django-countries==5.0
django-filter==1.0.4
django-solo==1.1.3
django-storages==1.6.5
djangorestframework==3.6.3
djoser==0.6.0
kombu==4.1.0
mysqlclient==1.3.10
Pillow==4.3.0
python-dotenv==0.6.4
python-magic==0.4.13
pytz==2017.2
redis==2.10.6
uWSGI==2.0.15
xlrd==1.2.0
I don't get any errors loading the packages; however, when I run the server I get this screenful of error messages:
(venv) C:\Users\romph\dev\EWO-DEV\backend>python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x000002A64687E0D0>
Traceback (most recent call last):
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\utils\autoreload.py", line 227, in wrapper fn(*args, **kwargs)
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run self.check(display_num_errors=True)
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\core\management\base.py", line 359, in check include_deployment_checks=include_deployment_checks,
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\core\management\base.py", line 346, in _run_checks return checks.run_checks(**kwargs)
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs)
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\core\checks\urls.py", line 16, in check_url_config return check_resolver(resolver)
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver return check_method()
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\urls\resolvers.py", line 254, in check for pattern in self.url_patterns:
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\urls\resolvers.py", line 405, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\urls\resolvers.py", line 398, in urlconf_module return import_module(self.urlconf_name)
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "C:\Users\romph\dev\EWO-DEV\backend\ewo\urls.py", line 51, in <module> url(r"^api/", include("apps.accounts.urls", namespace="accounts")),
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\django\conf\urls\__init__.py", line 50, in include urlconf_module = import_module(urlconf_module)
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "C:\Users\romph\dev\EWO-DEV\backend\apps\accounts\urls.py", line 5, in <module> from . import views
File "C:\Users\romph\dev\EWO-DEV\backend\apps\accounts\views.py", line 23, in <module> from .serializers import (
File "C:\Users\romph\dev\EWO-DEV\backend\apps\accounts\serializers.py", line 6, in <module> from apps.company.serializers import EmployeeSerializer
File "C:\Users\romph\dev\EWO-DEV\backend\apps\company\serializers.py", line 18, in <module> from apps.common.serializers import YesOrNoField
File "C:\Users\romph\dev\EWO-DEV\backend\apps\common\serializers.py", line 10, in <module> from .validators import CSVValidator, DocumentValidator
File "C:\Users\romph\dev\EWO-DEV\backend\apps\common\validators.py", line 6, in <module> import magic
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\magic\__init__.py", line 209, in <module> libmagic = loader.load_lib()
File "C:\Users\romph\.pyenv\pyenv-win\versions\3.6.1\lib\site-packages\magic\loader.py", line 49, in load_lib raise ImportError('failed to find libmagic. Check your installation')
That last line gives a pretty good clue.
Visit https://pypi.org/project/python-magic/
and follow the steps for Windows.
Windows
You'll need DLLs for libmagic. #julian-r maintains a pypi
package with the DLLs ...
You likely need to
pip install python-magic-bin
The requirements may have been specific to another os.

Getting error when Django startup with runserver command

I have an django app that include sklearn, pandas and numpy libraries. I can run it without virtualenv however when I run it inside virtualenv I get his error. I am using Python3.8 on Ubuntu. I just want to use virtualenv to manage my packages easily. I re-installed packages in the virtualenv with PyCharm. My error include references to the joblib library too.
I cannot find any solution:
Matching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/core/management/base.py", line 392, in check
all_issues = checks.run_checks(
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/core/checks/registry.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/urls/resolvers.py", line 408, in check
for pattern in self.url_patterns:
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/urls/resolvers.py", line 589, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/urls/resolvers.py", line 582, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/suat/Belgeler/github/turnusol/turnusolwebproject/urls.py", line 31, in <module>
path('factomat', include('factomat.urls')),
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/suat/Belgeler/github/turnusol/factomat/urls.py", line 2, in <module>
from . import views
File "/home/suat/Belgeler/github/turnusol/factomat/views.py", line 13, in <module>
from sklearn.externals import joblib
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/__init__.py", line 119, in <module>
from .parallel import Parallel
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/parallel.py", line 28, in <module>
from ._parallel_backends import (FallbackToBackend, MultiprocessingBackend,
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/_parallel_backends.py", line 22, in <module>
from .executor import get_memmapping_executor
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/executor.py", line 14, in <module>
from .externals.loky.reusable_executor import get_reusable_executor
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/loky/__init__.py", line 12, in <module>
from .backend.reduction import set_loky_pickler
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/loky/backend/reduction.py", line 125, in <module>
from sklearn.externals.joblib.externals import cloudpickle # noqa: F401
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/__init__.py", line 3, in <module>
from .cloudpickle import *
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 167, in <module>
_cell_set_template_code = _make_cell_set_template_code()
File "/home/suat/Belgeler/github/turnusol/venv/lib/python3.8/site-packages/sklearn/externals/joblib/externals/cloudpickle/cloudpickle.py", line 148, in _make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)
That looks like you may have run into a known issue with Python 3.8 and cloudpickle following changes in PEP 570.
It's not clear from the cloudpickle Github repo whether it supports Python 3.8 yet, so a potential fix may be to use Python 3.7 in the virtualenv instead.

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10deb92f0>

Having issues running django site with python3 manage.py runserver command. When starting, I get an error below:
MacBook-Pro-Lev:mysite levpolomosnov$ python3 manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.
<locals>.wrapper at 0x10deb92f0>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
self.check(display_num_errors=True)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 256, in check
for pattern in self.url_patterns:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 407, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 400, in urlconf_module
return import_module(self.urlconf_name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/levpolomosnov/Documents/mysite/mysite/urls.py", line 23, in <module>
from django.urls import include, path
ImportError: cannot import name 'include'
From django 2.0, include has been moved to django.urls. If you are using older django versions, then it might throw error. Please see the change log form django 2.0 regarding this issue.

Django, Running 'createsuperuser' on Visual Studio Command-line Error

Hi,
I want to user Python 3.7 and Django 2.1 in Visual Studio.
I just create a new Django project from Visual Studio. It creates the Python-Django project.
But when I try to run 'createsuperuser' command from command-line on
Visual Studio, I am getting this long error text.
I have the Python 3.7 and Django 2.1 version on my computer so I think It is not about the version.
How can I solve this problem?
Traceback (most recent call last):
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 59, in execute
return super().execute(*args, **options)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\base.py", line 350, in execute
self.check()
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\management\base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\urls\resolvers.py", line 396, in check
for pattern in self.url_patterns:
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\urls\resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "c:\users\misafir\source\repos\DjangoWebProject7\DjangoWebProject7\env\lib\site-packages\django\urls\resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Python\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File ".\DjangoWebProject7\urls.py", line 23, in <module>
django.contrib.auth.views.login,
AttributeError: module 'django.contrib.auth.views' has no attribute 'login'
django.contrib.auth.views.login has been removed in django 2.1. From the Release notes:
contrib.auth.views.login(), logout(), password_change(), password_change_done(), password_reset(), password_reset_done(), password_reset_confirm(), and password_reset_complete() are removed.
You should now use the class-based view django.contrib.auth.views.LoginView in your urls, e.g. in its simplest form:
path('login/', LoginView.as_view()),
module 'django.contrib.auth.views' has no attribute 'login'
the error is clearly showing....
i hope you are using Authentication Module that why you are facing this
It looks like you are using windows OS. From the traceback error I can see that you have not correctly installed django. Try creating a virtual environment for every project you create and install django there. It is a best developer practise.
This will clear you issue i hope so.
Cheers :)

Run Django Environment (for windows) with Tutorial - getting many errors

I'm setting up a Django Framework and I am doing so, using this Tutorial: https://docs.djangoproject.com/en/1.9/intro/tutorial01/. And before that I used this Tutorial to get started: https://docs.djangoproject.com/en/1.9/howto/windows/
I am basically done with the page, and when I run the last command 'python manage.py runserver' in the commandline it get a long error list, see below.
I have repeated the tutorial for about 3 times, and I installed django in my normal python enviroment and in the virtual environment. I ran 'python manage.py runserver' in every possible folder. - but I does not work. Can somebody tell me where I went wrong?
Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\Johanna>cd Envs\mysite
C:\Users\Johanna\Envs\mysite>python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03A6F198>
Traceback (most recent call last):
File "C:\Program Python\Python35-32\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\management\base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "C:\Program Python\Python35-32\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\checks\urls.py", line 10, in check_url_config
return check_resolver(resolver)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\checks\urls.py", line 19, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Program Python\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Program Python\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Program Python\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Program Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\Johanna\Envs\mysite\mysite\urls.py", line 20, in <module>
url(r'^polls/', include('polls.urls')),
NameError: name 'include' is not defined
Make sure your code in C:\Users\Johanna\Envs\mysite\mysite\urls.py is completely same as this
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^polls/', include('polls.urls')),
url(r'^admin/', admin.site.urls),
]
Especially, make sure that you have the top one line from django.conf.urls import include, url

Categories

Resources