> Also, are you sure a car exists with the id / pk you're passing? 

Turns out that's the problem. I wanted to use a field from my Car model: 
car_id, so the link on the website would look like: 
www.blablabla.com/cars/3421, where 3421 is the car_id. Unfortunately, the 
car_id is not the same as <pk>. Can I achieve something like that with 
class based generic views? And where do I look for different solution?

W dniu niedziela, 8 lipca 2012 11:20:44 UTC+2 użytkownik Thomas Orozco 
napisał:
>
> Could you give us the fill error message displaying what ended up being 
> passed to the view?
>
> Also, are you sure a car exists with the id / pk you're passing? 
> Le 7 juil. 2012 23:10, "Soviet" <soviet1...@gmail.com> a écrit :
>
>> 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" <soviet1...@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<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 <django-users%2bunsubscr...@googlegroups.com>.
>>>> For more options, visit this group at http://groups.google.com/**
>>>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>>> .
>>>>
>>>  -- 
>> 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/-/2RYQ-kplLroJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>

-- 
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/-/Bgkqud0CW2QJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to