def profile_edit(request): profile = request.user.get_profile() if request.method == 'POST': form = forms.ProfileEditForm(request.POST, request.FILES, instance=profile) if form.is_valid(): olang = get_language() activate(profile.preflang) messages.success(request, _('Profile updated')) form.save() next = reverse('users_profile_edit') next = force_language_in_url(next, olang, profile.preflang) return http.HttpResponseRedirect(next) else: messages.error(request, _('There were problems updating your ' 'profile. Please correct the problems ' 'and submit again.')) else: form = forms.ProfileEditForm(instance=profile) return render_to_response('users/profile_edit_main.html', { 'profile': profile, 'profile_form': form, 'general_tab': True, }, context_instance=RequestContext(request))
def profile_edit(request): profile = get_object_or_404(UserProfile, user=request.user) if request.method == 'POST': form = forms.ProfileEditForm(request.POST, request.FILES, instance=profile) if form.is_valid(): messages.success(request, _('Profile updated')) form.save() return http.HttpResponseRedirect(reverse('users_profile_edit'), ) else: messages.error( request, _('There were problems updating your ' 'profile. Please correct the problems ' 'and submit again.')) else: form = forms.ProfileEditForm(instance=profile) return render_to_response('users/profile_edit_main.html', { 'profile': profile, 'form': form, }, context_instance=RequestContext(request))