I think you can try to use a base view to handle the request and distribute
to sub functions. like:

def base_view(request):
    form_type = request.REQUEST.get("form_type", "1")
    if form_type == "1":
        result = sub_view1(request)
    ...
    else:
        result = sub_viewn(request)

    return http_response_obj

def sub_view1(request):
    ...
    return {"form": form1, "other_param": other}

def sub_viewn(request):
    ....

the `result` contains the `form` what the particular template form needs.
And the sub view has the `request`, so you can do almost everything like
real `view`.



2013/10/25 Faridul Islam <faridul.islam...@gmail.com>

> Hello Stodge,
>
> I was searching for an example of mutli-tab pages within a single view
> using Django and found your post which almost three years old. I am not
> sure whether you still work with Django or not. If you do, I will
> appreciate if you can share one example of it with me. FYI, this is my
> first time working with Django.
>
> Thanks.
>
> On Monday, September 13, 2010 6:48:21 AM UTC-5, Stodge wrote:
>
>> I'm working through a nice little feature for my website that will
>> bring all user editable preferences/profile options together into a
>> single web page using tabs. I have the tabs working and I can display
>> a different Django form on each tab but I'm confused how to tie it all
>> together using a view.
>>
>> Typically each form would be on a separate page using different views.
>> But how would I support say three forms on one page (in three tabs)? I
>> need one view to generate all of the tabs but one view can't support
>> three forms? What's the best way to implement this?
>>
>> Should I have three views to handle the POST requests for the three
>> forms and then a reusable function that renders the template?
>>
>> Thanks
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/bc38f4c1-0534-4adf-afd7-e53b9715b3bb%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANURRHCQoPqCMUhsVoWWKSzs-7QXfE1CYircjhZm3ShQOv%2BMdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to