Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#13623 closed (fixed)

Code in intro-tutorial03 missing a import statement

Reported by: lescoutinhovr@… Owned by: Horst Gutmann
Component: Documentation Version: dev
Severity: Keywords: tutorial
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Page: http://docs.djangoproject.com/en/dev/intro/tutorial03/#intro-tutorial03
Last code block. File: mysite/polls/urls.py
Missing code: from django.conf.urls.defaults import *

It is not an error because it says to "Copy the file mysite/urls.py to mysite/polls/urls.py.", but can lead to errors.

Attachments (2)

13623.diff (560 bytes ) - added by Horst Gutmann 14 years ago.
13623.2.diff (685 bytes ) - added by Tim Graham 14 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by Horst Gutmann, 14 years ago

Has patch: unset
Keywords: tutorial added
Owner: changed from nobody to Horst Gutmann
Triage Stage: UnreviewedAccepted
Version: 1.1SVN

While in general I'd agree, the snippets usually only contain the imports that are necessary for a certain example. In the examples above for views, for instance, render_to_response is not imported explicitly since the Http404 class is the only relevant import.

urlpatterns = patterns('mysite.polls.views',
    (r'^$', 'index'),
    (r'^(?P<poll_id>\d+)/$', 'detail'),
    (r'^(?P<poll_id>\d+)/results/$', 'results'),
    (r'^(?P<poll_id>\d+)/vote/$', 'vote'),
)

does not require the import since patterns was already introduced and no new function or required import is mentioned.

# ...
urlpatterns = patterns('',
    (r'^polls/', include('mysite.polls.urls')),
    # ...

on the other hand might benefit from the additional import statement since "include" is "new". Surely, it was imported previously but it should be re-iterated here where this function is coming from.

If you meant the second to last snippet on that page, then I agree ;-)

comment:2 by Sasha Romijn, 14 years ago

For newbie-friendlyness, I think all snippets in the tutorial should have all the imports included - it's only 2 or 3 in most cases anyways. I remember struggling a bit with finding the right imports, when I first did the tutorial

comment:3 by Horst Gutmann, 14 years ago

Good point, but we should probably put that into a different ticket since this, I guess, requires an OK by James.

by Horst Gutmann, 14 years ago

Attachment: 13623.diff added

comment:4 by Horst Gutmann, 14 years ago

Has patch: set

by Tim Graham, 14 years ago

Attachment: 13623.2.diff added

comment:5 by Tim Graham, 14 years ago

Triage Stage: AcceptedReady for checkin

I updated the patch to include a closing parens so that synatx highlighting works properly.

comment:6 by Luke Plant, 14 years ago

This is a dupe of #14142, which was closed 'invalid'. But since a few people are obviously tripping up, it's probably worth changing it.

comment:7 by Luke Plant, 14 years ago

Resolution: fixed
Status: newclosed

(In [13847]) Fixed #13623 - code in intro-tutorial03 missing an import statement

Thanks to lescoutinhovr@…, AMJ for the report, and to zerok/timo for
the patch.

comment:8 by Luke Plant, 14 years ago

(In [13848]) [1.2.X] Fixed #13623 - code in intro-tutorial03 missing an import statement

Thanks to lescoutinhovr@…, AMJ for the report, and to zerok/timo for
the patch.

Backport of [13847] from trunk

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