views:

314

answers:

1

Hi (sorry for my ugly english)

I wonder if this is possible to retrieve an object which was selected with the object_detail generic view. For example :

from django.views.generic.list_detail import object_detail

def my_view(request, slug)
    response = object_detail(request, MyModel.objects.all(), 
        slug=slug, 
        slug_field='slug',
        template_object_name='object')
    # Here I need my object in ``response`` to do something after.

I don't know where is the object

A: 

You can't get the object this way, since object_detail simply returns a rendered response. If you need it, you'll just have to get it manually:

object = MyModel.objects.get(slug=slug)
Daniel Roseman