views:

16

answers:

1

I have a model that has a template_name field and I have this generic view:

url(r'^/post/(?P<slug>[a-zA-Z0-9_.-]+)$', 'django.views.generic.list_detail.object_detail', {
        "template_object_name" : "post",
        'template_name': 'post_details.html'
    }, 'index')

How can I replace the template_name from 'post_details.html' to the template_name inside post?

+2  A: 

There is a template_name_field arg. By the way, your missing the queryset arg. It would look something like this:

url(r'^/post/(?P<slug>[a-zA-Z0-9_.-]+)$', 'django.views.generic.list_detail.object_detail', {
        "queryset": Post.objects.all(),
        "template_object_name" : "post",
        'template_name_field': 'template_name'
    }, 'index')
lenin