On Fri, 2006-05-12 at 13:30 +0200, [EMAIL PROTECTED] wrote: > Hi, > > According to the documentation, the generic view > 'object_detail' requires a QuerySet parameter and the > object_id. Before MR, it required only a model class and the > object_id (more logical to me).
It takes a QuerySet now so that it is consistent with the rest of the generic views (they all take QuerySets). > What does this QuerySet look like? > It works if I use MyModel.objects.all(), but I doubt I need > the whole list when I want to show only one item? And I can't > pass the object_id at the URLConf level... Keep in mind that QuerySets are "lazy". So you might as well pass in MyModel.objects.all(). It does not get evaluated until needed and for the object_detail() method, it ends up retrieving the records that match MyModel.objects.all().get(pk = object_id) which will only be a single record retrieval. So this is not inefficient at all. You can pass the object_id in from the URLConf level, by the way. Have a look at the first example in docs/generic_views.txt (online at http://www.djangoproject.com/documentation/generic_views/ ). It creates the info_dict containing the QuerySet and then adds in the slug_field parameter that it extracts from the URL. That is for date-based views, but object_details views will be similar. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---