Code

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13623 closed (fixed)

Code in intro-tutorial03 missing a import statement

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

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 zerok 4 years ago.
13623.2.diff (685 bytes) - added by timo 4 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 4 years ago by zerok

  • Has patch unset
  • Keywords tutorial added
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to zerok
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Version changed from 1.1 to SVN

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 Changed 4 years ago by erikr

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 Changed 4 years ago by zerok

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

Changed 4 years ago by zerok

comment:4 Changed 4 years ago by zerok

  • Has patch set

Changed 4 years ago by timo

comment:5 Changed 4 years ago by timo

  • Triage Stage changed from Accepted to Ready for checkin

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

comment:6 Changed 4 years ago by lukeplant

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 Changed 4 years ago by lukeplant

  • Resolution set to fixed
  • Status changed from new to closed

(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 Changed 4 years ago by lukeplant

(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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.