Thursday, September 8, 2011

Binding two views to one url?

Is it possible to bind two views to one url adress?

I have a generic view - detail_view and I prepared a form for comments.
Detail_views generates urls by "type", "pk", "slug" fields. Under each publication I'd like to add a form to add my comments model and I dont really know how I could do that.

URL - detail view:

url(r'^(?P<type>[\w\-_]+)/(?P<pk>\d+)/(?P<slug>[\w\-_]+)/$',
        DetailView.as_view(
                         model=Publisher,
                         template_name='templates/publications/single.html',
                            ),

                         name = "single_publication"
                         ),

VIEW for form:
def add_comment(request, type, pk, slug):
    form = CommentsForm()
    return render_to_response('templates/publications/single.html', {'form':form}, context_instance=RequestContext(request))

--
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/-/Ke3ot3Kjd-8J.
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.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment