xmpp.chapril.org-conversejs/accounts/views.py

22 lines
715 B
Python
Raw Normal View History

2012-03-02 16:16:20 +01:00
from django.shortcuts import render_to_response
from django.template import RequestContext
2012-03-02 16:38:41 +01:00
from accounts.forms import ProfileForm, UserForm
2012-03-02 16:16:20 +01:00
def profile(request):
if request.method == 'POST':
2012-03-02 16:38:41 +01:00
form = ProfileForm(request.POST, instance = request.user.get_profile())
userform = UserForm(request.POST, instance = request.user)
if form.is_valid() and userform.is_valid():
form.save()
userform.save()
2012-03-02 16:16:20 +01:00
else:
form = ProfileForm(instance = request.user.get_profile())
2012-03-02 16:38:41 +01:00
userform = UserForm(instance = request.user)
2012-03-02 16:16:20 +01:00
2012-03-02 16:38:41 +01:00
return render_to_response('profile.html', RequestContext(request, {
'form': form,
'userform': userform,
}))