On 07/07/2012 10:36 PM, Soviet 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 [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
The parameters are from url and automatically passed to your view, i don't have to pass them explicitily, take a look on
https://docs.djangoproject.com/en/1.3//topics/http/urls/

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

Reply via email to