[Django] #25473: Docs: 'author-detail' vs 'author_update'

13 views
Skip to first unread message

Django

unread,
Sep 26, 2015, 12:38:16 PM9/26/15
to django-...@googlegroups.com
#25473: Docs: 'author-detail' vs 'author_update'
--------------------------------------+--------------------
Reporter: guettli | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
Please use **one** form to refer to the update-view of
a model.

Here are two: 'author-detail' vs 'author_update'

{{{
def get_absolute_url(self):
return reverse('author-detail', kwargs={'pk': self.pk})
}}}

from https://docs.djangoproject.com/en/1.8/topics/class-based-views
/generic-editing/#model-forms

some lines below the above link:
{{{
url(r'author/(?P<pk>[0-9]+)/$', AuthorUpdate.as_view(),
name='author_update'),
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25473>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 26, 2015, 12:52:03 PM9/26/15
to django-...@googlegroups.com
#25473: Docs: 'author-detail' vs 'author_update'
-------------------------------------+-------------------------------------
Reporter: guettli | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by guettli):

* needs_docs: => 0
* needs_tests: => 0
* needs_better_patch: => 0


Old description:

> Please use **one** form to refer to the update-view of
> a model.
>
> Here are two: 'author-detail' vs 'author_update'
>
> {{{
> def get_absolute_url(self):
> return reverse('author-detail', kwargs={'pk': self.pk})
> }}}
>
> from https://docs.djangoproject.com/en/1.8/topics/class-based-views
> /generic-editing/#model-forms
>
> some lines below the above link:
> {{{
> url(r'author/(?P<pk>[0-9]+)/$', AuthorUpdate.as_view(),
> name='author_update'),
> }}}

New description:

Please use **one** form to refer to the update-view of
a model.

Here are two: 'author-detail' vs 'author_update'

{{{
def get_absolute_url(self):
return reverse('author-detail', kwargs={'pk': self.pk})
}}}

from https://docs.djangoproject.com/en/1.8/topics/class-based-views
/generic-editing/#model-forms

some lines below the above link:
{{{
url(r'author/(?P<pk>[0-9]+)/$', AuthorUpdate.as_view(),
name='author_update'),
}}}


But first: The django core developers should decide which pattern should
be used in the docs:

foo-detail or foo_update.

When the decision was made, then all examples in the docs should use this
pattern.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:1>

Django

unread,
Sep 26, 2015, 1:20:27 PM9/26/15
to django-...@googlegroups.com
#25473: Docs: 'author-detail' vs 'author_update'
-------------------------------------+-------------------------------------
Reporter: guettli | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by claudep):

Can you please clarify what is the precise object of this ticket? Is this
the hyphen vs underscore in the view name? Because detail and update views
are different views...

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:2>

Django

unread,
Sep 26, 2015, 1:55:48 PM9/26/15
to django-...@googlegroups.com
#25473: Docs: 'author-detail' vs 'author_update'
-------------------------------------+-------------------------------------
Reporter: guettli | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

It looks to me like the complaint is that sometimes dashes are used in
`url()` names, sometimes underscores. If I had to cast a vote, I guess I'd
choose dashes based on Google's advice "We recommend that you use hyphens
(-) instead of underscores (_) in your URLs." and the fact that you might
want your URL names to roughly match the URLs themselves.

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:3>

Django

unread,
Sep 28, 2015, 2:45:52 AM9/28/15
to django-...@googlegroups.com
#25473: Docs: 'author-detail' vs 'author_update'
-------------------------------------+-------------------------------------
Reporter: guettli | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by guettli):

Yes, this ticket is not about technical details, it is about the Zen of
Python:

"There should be one-- and preferably only one --obvious way to do it."

It least the django docs should be consistently use hyphens xor underscore
for url names.

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:4>

Django

unread,
Sep 28, 2015, 11:06:09 AM9/28/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
--------------------------------------+------------------------------------

Reporter: guettli | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Note that we cannot change some examples like `url(r'^reset/done/$',
auth_views.password_reset_complete, name='password_reset_complete')` in
`docs/ref/contrib/admin/index.txt` as Django templates use those names in
templates.

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:5>

Django

unread,
Oct 4, 2015, 12:19:12 AM10/4/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
--------------------------------------+------------------------------------
Reporter: guettli | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by amites):

or perhaps the scope of this ticket could be expanded to include updating
the bundled templates

perhaps add a DEPRECATED / duplicate of urlpatterns that include all the
old underscore naming?

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:6>

Django

unread,
Oct 4, 2015, 2:18:01 AM10/4/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
--------------------------------------+------------------------------------
Reporter: guettli | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by wimfeijen):

Hi guys,

My preference would be to use underscores in stead of dashes, because we
are coupling urls to views, and in function based views, view names always
use underscores instead of dashes.

My personal preference is to have url names, view names and template names
the same, all using underscores.

My url patterns tend to differ anyway, containing dashes, slug regexes and
such.

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:7>

Django

unread,
Oct 4, 2015, 5:40:29 AM10/4/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
--------------------------------------+------------------------------------
Reporter: guettli | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by aaugustin):

The counter-argument is that using a different convention for different
types of objects makes it easier to search or replace one type and not the
others.

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:8>

Django

unread,
Oct 5, 2015, 3:25:12 AM10/5/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
--------------------------------------+------------------------------------
Reporter: guettli | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by guettli):

What kind of types do you have? Can you please list some. I could guess
what you mean, but I don't like guessing.

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:9>

Django

unread,
Oct 5, 2015, 3:04:17 PM10/5/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
--------------------------------------+------------------------------------
Reporter: guettli | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by aaugustin):

Here are the three conventions and the types they're commonly used for:

- `dash-separated`: URL names
- `underscore_separated`: FBV function names
- `CamelCase`: CBV class names and other classes: models, forms, etc.

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:10>

Django

unread,
Oct 6, 2015, 4:24:37 AM10/6/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
--------------------------------------+------------------------------------
Reporter: guettli | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by guettli):

You wrote "The counter-argument is that using a different convention for


different types of objects makes it easier to search or replace one type
and not the others."

I understood that there are different types of url-names. But that was my
mistake.

I guess I understood you now: You want dash-seperated of the url names,
since .. it makes it easier to search or replace one type and not the
others. Correct?

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:11>

Django

unread,
Oct 6, 2015, 5:22:54 AM10/6/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
--------------------------------------+------------------------------------
Reporter: guettli | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by aaugustin):

Exactly. Sorry for not expressing that clearly.

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:12>

Django

unread,
Oct 13, 2015, 8:52:08 AM10/13/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
-------------------------------------+-------------------------------------
Reporter: guettli | Owner:
Type: | Gayathrimenakath
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.8

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gayathrimenakath):

* status: new => assigned
* owner: nobody => Gayathrimenakath


--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:13>

Django

unread,
Oct 13, 2015, 8:58:21 AM10/13/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
-------------------------------------+-------------------------------------
Reporter: guettli | Owner:
Type: | Gayathrimenakath
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.8

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Gayathrimenakath):

* cc: Gayathrimenakath (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:14>

Django

unread,
Nov 7, 2015, 6:20:05 AM11/7/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
--------------------------------------+------------------------------------
Reporter: guettli | Owner: elenaoat
Type: Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.8

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by elenaoat):

* owner: Gayathrimenakath => elenaoat


--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:15>

Django

unread,
Nov 7, 2015, 6:35:40 AM11/7/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
--------------------------------------+------------------------------------
Reporter: guettli | Owner:
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by elenaoat):

* owner: elenaoat =>
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:16>

Django

unread,
Nov 7, 2015, 8:43:35 AM11/7/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
-------------------------------------+-------------------------------------
Reporter: guettli | Owner:
Type: | thijsvandien
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.8

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by thijsvandien):

* status: new => assigned

* owner: => thijsvandien


--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:17>

Django

unread,
Nov 7, 2015, 10:26:17 AM11/7/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
-------------------------------------+-------------------------------------
Reporter: guettli | Owner:
Type: | thijsvandien
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 1.8

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by thijsvandien):

* has_patch: 0 => 1


Comment:

Pull request at https://github.com/django/django/pull/5593

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:18>

Django

unread,
Nov 7, 2015, 3:59:54 PM11/7/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
-------------------------------------+-------------------------------------
Reporter: guettli | Owner:
Type: | thijsvandien
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.8
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"1679472165e840aef4c8c9ece2fbf4620b87beab" 16794721]:
{{{
#!CommitTicketReference repository=""
revision="1679472165e840aef4c8c9ece2fbf4620b87beab"
Fixed #25473 -- Changed underscores in url() names to dashes in docs.

To improve consistency, sample URL names that had underscores
in them now use dashes instead. That excludes URL names that
have some relation to the code, such as those generated by
the admin.

Thanks guettli for reporting this.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:19>

Django

unread,
Nov 7, 2015, 4:02:18 PM11/7/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
-------------------------------------+-------------------------------------
Reporter: guettli | Owner:
Type: | thijsvandien
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.8

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"f5e1d72de2e111ef2449f858b672c9cf4ecbb9ff" f5e1d72]:
{{{
#!CommitTicketReference repository=""
revision="f5e1d72de2e111ef2449f858b672c9cf4ecbb9ff"
[1.9.x] Fixed #25473 -- Changed underscores in url() names to dashes in
docs.

To improve consistency, sample URL names that had underscores
in them now use dashes instead. That excludes URL names that
have some relation to the code, such as those generated by
the admin.

Thanks guettli for reporting this.

Backport of 1679472165e840aef4c8c9ece2fbf4620b87beab from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:20>

Django

unread,
Nov 7, 2015, 4:02:19 PM11/7/15
to django-...@googlegroups.com
#25473: Consistently use dashes instead of underscores in URL names
-------------------------------------+-------------------------------------
Reporter: guettli | Owner:
Type: | thijsvandien
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.8

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"78a28cca200e6e03432bab9bf73856b8f778c6f0" 78a28cca]:
{{{
#!CommitTicketReference repository=""
revision="78a28cca200e6e03432bab9bf73856b8f778c6f0"
[1.8.x] Fixed #25473 -- Changed underscores in url() names to dashes in
docs.

To improve consistency, sample URL names that had underscores
in them now use dashes instead. That excludes URL names that
have some relation to the code, such as those generated by
the admin.

Thanks guettli for reporting this.

Backport of 1679472165e840aef4c8c9ece2fbf4620b87beab from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25473#comment:21>

Reply all
Reply to author
Forward
0 new messages