If you use "DetailView"
(https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-display
/#django.views.generic.detail.DetailView) you may call this field "slug" (it
is default). But you can overwrite it.

But in your case custom function is used, so you may call this field
whatever you want. 
I believe "id" is nice.

I use DetailView unless I need really custom logic, so I use "slug" almost
always.

Ilya Kazakevich,
JetBrains PyCharm (Best Python/Django IDE)
http://www.jetbrains.com/pycharm/
"Develop with pleasure!"


>-----Original Message-----
>From: django-users@googlegroups.com
>[mailto:django-users@googlegroups.com] On Behalf Of Thomas Guttler
>Sent: Wednesday, June 04, 2014 5:07 PM
>To: django-users@googlegroups.com
>Subject: URLs: mymodel_id vs object_id vs pk ....
>
>What is the best practice for named URL parameter which refer to a primary
key
>of a model?
>
>I have seen many ways:
>
>  - object_id
>  - mymodel_id
>  - pk
>  - id
>  - .....
>
>example:
>
>urlpatterns = [
>     url(r'^article/(?P<WHAT_NAME_HERE>\d+)/$', 'article.view'),
>     ...
>     ]
>
>Up to now we used "mymodel_id" but it gets boring to type in "mymodel".
>
>This is a question about best practice:
>
>Which do you use (and why)?
>
>
>Related:
>https://docs.djangoproject.com/en/dev/topics/http/urls/#named-groups
>
>   Thomas
>
>--
>You received this message because you are subscribed to the Google Groups
>"Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send an
email to
>django-users+unsubscr...@googlegroups.com.
>To post to this group, send email to django-users@googlegroups.com.
>Visit this group at http://groups.google.com/group/django-users.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/538F19FF.1090209%40tbz-pari
>v.de.
>For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/03fe01cf7ff8%24c969ba00%245c3d2e00%24%40JetBrains.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to