#15508: DetailView view looks for pk or slug by default but the error says id or
slug.
-----------------------------------------+----------------------------------
               Reporter:  varikin        |         Owner:  nobody   
                 Status:  new            |     Milestone:           
              Component:  Generic views  |       Version:  1.3-alpha
             Resolution:                 |      Keywords:           
           Triage Stage:  Accepted       |     Has patch:  0        
    Needs documentation:  0              |   Needs tests:  0        
Patch needs improvement:  0              |  
-----------------------------------------+----------------------------------
Changes (by russellm):

  * needs_better_patch:  => 0
  * needs_docs:  => 0
  * needs_tests:  => 0
  * stage:  Unreviewed => Accepted


Old description:

> With the following url rule
>
>     url(r'^order/(?P<id>\d+)/$', DetailView.as_view(model=Order), name
> ='order-detail')
>
> Django throws the following error:
>
>     Generic detail view order must be called with either an object id or
> a slug.
>
> From django/django/views/generic/detail.py in get_object, line 45
>
> It confused me for a bit because I am supplying the id of the object.
> Upon looking at detail.py, it looks for pk and slug. I checked the
> documentation and found that does mention pk and slug as well, so I am
> obviously doing it wrong. But, in my mind, id also makes sense. But
> whether support for id is added or not, I think the error message should
> be updated to say 'object pk or a slug'.
>
> I am running 1.3 alpha at the moment, but I checked the method trunk it
> is the same.

New description:

 With the following url rule
 {{{
     url(r'^order/(?P<id>\d+)/$', DetailView.as_view(model=Order), name
 ='order-detail')
 }}}
 Django throws the following error:
 {{{
     Generic detail view order must be called with either an object id or a
 slug.
 }}}
 From django/django/views/generic/detail.py in get_object, line 45

 It confused me for a bit because I am supplying the id of the object. Upon
 looking at detail.py, it looks for pk and slug. I checked the
 documentation and found that does mention pk and slug as well, so I am
 obviously doing it wrong. But, in my mind, id also makes sense. But
 whether support for id is added or not, I think the error message should
 be updated to say 'object pk or a slug'.

 I am running 1.3 alpha at the moment, but I checked the method trunk it is
 the same.

--

Comment:

 Good catch -- you're absolutely correct. I'll commit a fix shortly.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15508#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to