"py manage.py runserver" gives loads of errors

The errors suggest that it does not recognise django even though it is installed.

I ran “C:\Users(…)\project-name\mysite>py manage.py runserver” using cmd prompt

I did “C:\Users(…)\project-name\mysite>pip list” which gave:

Package Version


asgiref 3.8.1
colorama 0.4.6
Django 5.1.1
pip 24.2
pygame 2.5.2
sqlparse 0.5.1
tzdata 2024.2

no idea what that means tho

I did ensure that python and django were fully up to date

I used VS Code for a bit maybe that messed it up somehow??

I would really appreciate help because I’ve been stuck on this for 2 days

Please share screenshot of the error stacktrace

Welcome @nighttimedaydreamer !

Please do NOT post images of errors or other textual information.

Copy/paste the text of the error into the body of your post as a code block.

Also, based upon what I can read of that image, post the contents of your mysite\urls.py file.

@mkalioby - Please do not encourage people to post screen shots. It’s requested that this type of information be posted as text.

1 Like

I replaced my name with (…) as I don’t want that to be quite so easy to find

Microsoft Windows [Version 10.0.22631.4169]
(c) Microsoft Corporation. All rights reserved.

C:\Users\(...)>cd C:\Users\anyat\Documents\project-name\mysite

C:\Users\(...)\Documents\project-name\mysite>py manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1075, in _bootstrap_inner
    self.run()
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1012, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\commands\runserver.py", line 134, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\management\base.py", line 486, in check
    all_issues = checks.run_checks(
                 ^^^^^^^^^^^^^^^^^^
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\checks\urls.py", line 44, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\core\checks\urls.py", line 63, in _load_all_namespaces
    url_patterns = getattr(resolver, "url_patterns", [])
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\functional.py", line 47, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
                                         ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\urls\resolvers.py", line 718, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
                       ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\utils\functional.py", line 47, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
                                         ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\site-packages\django\urls\resolvers.py", line 711, in urlconf_module
    return import_module(self.urlconf_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\(...)\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "C:\Users\(...)\Documents\project-name\mysite\mysite\urls.py", line 21, in <module>
    path("polls/", include("polls.urls")),
                   ^^^^^^^
NameError: name 'include' is not defined

Just to clarify, my mysite\urls.py is from the tutorial, but here it is:

from django.contrib import admin
from django.urls import path

urlpatterns = [
    path("polls/", include("polls.urls")),
    path("admin/", admin.site.urls),
]

also I’m not convinced i know what a stacktrace is

Compare what you have in your urls.py file with what the tutorial is telling you you should have.

See mysite/urls.py and the block of text immediately above it.

1 Like

Thank you! And apologies for my incredible stupidity!

No worries - no apologies necessary or warranted. It’s all part of the learning process.