Opened 6 years ago

Closed 6 years ago

#28962 closed Cleanup/optimization (needsinfo)

Documentation of use of template tags in forms

Reported by: Malik A. Rumi Owned by: nobody
Component: Documentation Version: 2.0
Severity: Normal Keywords: forms, templatetags, urls
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I'm wondering why both https://docs.djangoproject.com/en/1.11/topics/class-based-views/mixins/#using-formmixin-with-detailview and https://docs.djangoproject.com/en/2.0/topics/auth/default/ have no explicit discussion of the use of template tags, and the latter page only has a couple of one line examples? Other than that, you seem to be recommending the use of hard coded urls, which I thought was strange, but maybe has a purpose I am not aware of? Thx.

Change History (2)

comment:1 by Tim Graham, 6 years ago

I guess you're referring to an example like:

@permission_required('polls.can_vote', login_url='/loginpage/')

which instead could be something like (untested):

@permission_required('polls.can_vote', login_url=reverse_lazy('some-page-nam'`))

(I think you mixed up terminology in calling reverse() and reverse_lazy() "template tags"... probably you were thinking of the {% url %} tag.)

I don't know if we should try to avoid hardcoding URLs in all examples. It may make things a bit less readable. Nor am I sure if it's beneficial to mention everywhere a URL is accepted that you can also use reverse() to avoid hardcoding one. The topic of hardcoding URLs is discussed in the tutorial, so hopefully a Django user would remember that and not need a constant reminder.

comment:2 by Tim Graham, 6 years ago

Resolution: needsinfo
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top