RE: Problem with DetailView
More data would be nice. What url are you goimg to that's failing, exactly? Are you clicking a link from your ListView? If so, could you show your template?
-----Mensaje original-----
De: Soviet
Enviados: 07/07/2012 18:10:17
Asunto: Re: Problem with DetailView
But the ListView is working fine. And they don't use <pk> in the
documentation, just this, which I modified to fit my model:
urlpatterns = patterns('',
(r'^publishers/$', ListView.as_view(
model=Publisher,
)),
)
W dniu sobota, 7 lipca 2012 22:44:23 UTC+2 użytkownik Sam007 napisał:
>
> If I am not wrong. The issue is with the List View not Detail View.
>
> You need to provide, List View with query set. If you are providing model
> parameter, you will also need to give it a primary key 'pk', like you did
> for Detail View.
>
> Hope that helps,
> Smaran
> On Jul 7, 2012 3:36 PM, "Soviet" <soviet1337@gmail.com> wrote:
>
>> Now that I have basic understanding of models, I encountered even more
>> confusing subjects - views and urls. Now, the class-generic views are quite
>> easy to grasp at basic level, but I fail to understand what's wrong with
>> this code:
>>
>> urlpatterns = patterns('',
>> (r'^$', ListView.as_view(
>> model=Car,
>> context_object_name="cars_list",
>> template_name='data/cars_list.html',
>> )),
>> (r'^(?P<pk>\d+)/$', DetailView.as_view(
>> model=Car,
>> context_object_name="car_details",
>> template_name='data/car_details.html',
>> )),
>> )
>>
>> The ListView is working fine, but when I try to get the details about
>> single car, all I'm getting is error: "No car found matching the query". I
>> tried adding 'queryset = Car.objects.all()' both in urls.py and in
>> views.py, creating custom class, but the error persists.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/fQZA1sl13VkJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscribe@googlegroups.com.
>
Correo truncado a 2,000 caracteres.
:::0:a0e2896b0575c65d30a12e3ca365460d:7d0::::
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home