You should make sure you import the module polls in the site01/urls.py file by adding this line:

from polls import views


Le 23/03/2019 à 19:47, Ben Edwards a écrit :
Ive not done https://docs.djangoproject.com/en/2.1/intro/tutorial01/ 3 times and cant get past the first page.  Its kind of dryving me nuts.

Where I am at is in github https://github.com/ben-tvpp/site01

Ive added the view https://github.com/ben-tvpp/site01/blob/master/polls/views.py


    # Create your views here.


    from django.http import HttpResponse



    def index(request):

    return HttpResponse("Hello, world. You're at the polls index.")

    from django.shortcuts import render


And the urls https://github.com/ben-tvpp/site01/blob/master/site01/urls.py

    from django.urls import include, path


    urlpatterns = [

    path('polls/', include('polls.urls')),

    path('admin/', admin.site.urls),

    ]


And even tried adding polls to https://github.com/ben-tvpp/site01/blob/master/site01/settings.py

but when I run the server

site01$ python manage.py runserverIget the below error.

    Traceback (most recent call last):

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/autoreload.py",
    line 225, in wrapper

    fn(*args, **kwargs)

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/commands/runserver.py",
    line 117, in inner_run

    self.check(display_num_errors=True)

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/base.py",
    line 379, in check

    include_deployment_checks=include_deployment_checks,

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/management/base.py",
    line 366, in _run_checks

    return checks.run_checks(**kwargs)

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/registry.py",
    line 71, in run_checks

    new_errors = check(app_configs=app_configs)

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/urls.py",
    line 40, in check_url_namespaces_unique

    all_namespaces = _load_all_namespaces(resolver)

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/core/checks/urls.py",
    line 57, in _load_all_namespaces

    url_patterns = getattr(resolver, 'url_patterns', [])

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/functional.py",
    line 37, in __get__

    res = instance.__dict__[self.name] = self.func(instance)

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/resolvers.py",
    line 533, in url_patterns

    patterns = getattr(self.urlconf_module, "urlpatterns",
    self.urlconf_module)

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/utils/functional.py",
    line 37, in __get__

    res = instance.__dict__[self.name] = self.func(instance)

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/resolvers.py",
    line 526, in urlconf_module

    return import_module(self.urlconf_name)

    File
    "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/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 "/mnt/d/django/site01/site01/urls.py", line 20, in <module>

    path('polls/', include('polls.urls')),

    File
    
"/home/ben/.pyenv/versions/3.7.2/lib/python3.7/site-packages/django/urls/conf.py",
    line 34, in include

    urlconf_module = import_module(urlconf_module)

    File
    "/home/ben/.pyenv/versions/3.7.2/lib/python3.7/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 965, in
    _find_and_load_unlocked

    ModuleNotFoundError: No module named 'polls.urls'
    Unhandled exception in thread started by <function
    check_errors.<locals>.wrapper at 0x7f1477b8eea0>







--
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 [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
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/44655cc2-6e6d-4a31-8249-3a1f84e5f2d4%40googlegroups.com <https://groups.google.com/d/msgid/django-users/44655cc2-6e6d-4a31-8249-3a1f84e5f2d4%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
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 [email protected].
To post to this group, send email to [email protected].
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/53a527be-86e9-d134-54c0-a4e1e71e4fa6%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to