Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#31467 closed Bug (invalid)

Possible error in the doc "Writing your first Django app, part 1".

Reported by: Marc-Antoine Daneau Owned by: nobody
Component: Documentation Version: 3.0
Severity: Normal Keywords:
Cc: Marc-Antoine Daneau Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

There is something not working in the first step of the Django tutorial.

near the end of the page, mysite/urls.py is defined as :

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

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

When I runserver with this, I got the error :

 File "/home/myuser/dev/mysite1/mysite1/urls.py", line 25, in <module>
    path('polls/', include('polls.urls')),
NameError: name 'include' is not defined

To solve this, I added this to mysite/urls.py :

from django.conf.urls import include

I'm not sure this is the best way to solve the error, but it works. Thanks.

Change History (2)

comment:1 by Mariusz Felisiak, 4 years ago

Has patch: unset
Resolution: invalid
Status: newclosed
Summary: Possible error in the doc "Writing your first Django app, part 1"Possible error in the doc "Writing your first Django app, part 1".

You probably missed this import at the top of your file:

from django.urls import include, path

Closing per TicketClosingReasons/UseSupportChannels.

comment:2 by Marc-Antoine Daneau, 4 years ago

Cc: Marc-Antoine Daneau added

Thank you for the reply. And in fact, of course I missed it, because it is not in the doc.

Note: See TracTickets for help on using tickets.
Back to Top