I have profile edit page with several tabs. Each tab is a separate page, so when I access it, I add "tab" parameter:
/edit/?tab=general
/edit/?tab=contacts
When user finishes to fill a form on one of these tabs (for example, /edit/?tab=general), he submit it. If form is not valid, I need to render it with errors. Browser URL input need to be filled with /edit/?tab=general, but when I render page, URL is /edit/.
Can I change it somehow? Thanks.
Code:
def _profile_edit_general(request):
profile = request.user.get_profile()
if request.method == 'POST':
form = forms.ProfileEditGeneralForm(request.POST, instance=profile)
if form.is_valid():
form.save()
else:
form = forms.ProfileEditGeneralForm(instance=profile)
return render_template(request, 'profiles/edit/general.html', {
'profile_edit_general_form': form
})
@login_required
def profile_edit(request):
if request.method == 'POST':
if 'profile_edit_general_submit' in request.POST:
return _profile_edit_general(request)
else:
tab = request.GET.get('tab')
if tab == 'general':
return _profile_edit_general(request)
else:
return Http404