Django

Code

Ticket #4355 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

Confusing example in documentation for url template tag

Reported by: Collin Grady <cgrady@the-magi.us> Assigned to: jacob
Milestone: Component: Documentation
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The documentation for the url template tag shows it linking to a view as 'app_name.client' which would require a very abnormal project setup to be valid - because of this, it can be confusing to newer django users - I was helping someone on IRC that thought the tag did some translation from app.viewname to project.app.views.viewname :)

Attachments

url-doc.patch (1.0 kB) - added by Collin Grady <cgrady@the-magi.us> on 05/21/07 16:31:32.
url-doc.2.patch (1.0 kB) - added by Marc Fargas <telenieko@telenieko.com> on 05/21/07 17:26:23.
stripped the project_name

Change History

05/21/07 16:31:32 changed by Collin Grady <cgrady@the-magi.us>

  • attachment url-doc.patch added.

05/21/07 17:19:00 changed by Marc Fargas <telenieko@telenieko.com>

  • stage changed from Unreviewed to Ready for checkin.

Yes, it's better to stay consistent across the documentation!

(follow-up: ↓ 4 ) 05/21/07 17:20:14 changed by mtredinnick

  • needs_better_patch set to 1.
  • stage changed from Ready for checkin to Accepted.

Leave the project name out of the change, though, that makes things less portable (because if you move the app to somewhere else on your Python path, you have to change every URLConf entry that refers to it). Including "viewe" makes sense, though.

(follow-up: ↓ 5 ) 05/21/07 17:22:32 changed by Collin Grady <cgrady@the-magi.us>

project_name is used elsewhere though, including in that very same example (the include line) - should that be changed also?

(in reply to: ↑ 2 ) 05/21/07 17:26:08 changed by Marc Fargas <telenieko@telenieko.com>

Replying to mtredinnick:

Leave the project name out of the change, though, that makes things less portable (because if you move the app to somewhere else on your Python path, you have to change every URLConf entry that refers to it). Including "viewe" makes sense, though.

I agree that including the project name makes things less portable but starting at the tutorial 01 http://www.djangoproject.com/documentation/tutorial01/#playing-with-the-api we are telling newcomers to include it (mysite in this case) so we should a) recommend it b) don't do it. But being consistent as much as possible on all the docs/

I'd rather go for the "do not recommend including the project name on imports" but on the whole docs ;)

Anyway, updated patch follows.

05/21/07 17:26:23 changed by Marc Fargas <telenieko@telenieko.com>

  • attachment url-doc.2.patch added.

stripped the project_name

(in reply to: ↑ 3 ; follow-up: ↓ 7 ) 05/21/07 17:31:16 changed by Marc Fargas <telenieko@telenieko.com>

Replying to Collin Grady <cgrady@the-magi.us>:

project_name is used elsewhere though, including in that very same example (the include line) - should that be changed also?

You're right, project_name is used in the middle of the section the patch correct which makes it sound strange. Let's let triagers decide whether to apply the first patch or making a new one changing all project_name references on templates.txt

(which means: do not apply the second patch as it makes the section sound strange''')

05/21/07 18:39:43 changed by SmileyChris

  • needs_better_patch deleted.
  • stage changed from Accepted to Ready for checkin.

Consistency is good. I say apply the first patch and open a new ticket to remove the project_name references throughout the templates doc file.

(in reply to: ↑ 5 ) 05/26/07 04:42:29 changed by mtredinnick

Replying to Marc Fargas <telenieko@telenieko.com>:

... decide whether to apply the first patch or making a new one changing all project_name references on templates.txt

The only other reference to project_name in that whole file is in a completely different context: it's two lines later showing how the project-wide !URLConf file might include the app-specific !URLConf. Not a bad place to use the project name.

There's no inconsistency at all here (tutorials are not the same as reference document; don't conflate the two). Using project name sometimes and not others is not a disaster. Certainly not in this case.

05/26/07 04:43:32 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [5353]) Fixed #4355 -- Clarified a confusing example in the use of the url template tag. Based on a patch from Collin Grady.

05/26/07 23:02:36 changed by Collin Grady <cgrady@the-magi.us>

But won't only one of the two methods work depending on your pythonpath setup? (unless you're in a file in the project root)

Seems like an important bit of inconsistency :)

05/26/07 23:07:57 changed by mtredinnick

The first line is in the app dir, the second line is in the project's URL conf -- that is clear in the example -- so both have their own directory in their effective Python import path. The docs say "if is is included like this", setting up the precondition. It doesn't say you have to import it like that. We are not spoon-feeding here, intentionally; that drags down the quality of the docs for the other 90% of readers. If somebody need to stop and think for a minute to get the example straight, no harm is done.

There really are far more important problems to fix than going around and around on this. Let's move on, please.


Add/Change #4355 (Confusing example in documentation for url template tag)




Change Properties
Action