diff --git a/nsupdate/accounts/forms.py b/nsupdate/accounts/forms.py new file mode 100644 index 0000000..ac33696 --- /dev/null +++ b/nsupdate/accounts/forms.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- + +from django import forms +from django.contrib.auth.models import User + +class UserProfileForm(forms.ModelForm): + class Meta: + model = User + fields = ['first_name', 'last_name', ] + diff --git a/nsupdate/accounts/templates/accounts/user_profile.html b/nsupdate/accounts/templates/accounts/user_profile.html index 9abad34..774ab56 100644 --- a/nsupdate/accounts/templates/accounts/user_profile.html +++ b/nsupdate/accounts/templates/accounts/user_profile.html @@ -1,5 +1,16 @@ {% extends "base.html" %} +{% load bootstrap %} {% block content %}

Hi, {{ request.user.username }}

+

Your data:

+
+
+
+ {% csrf_token %} + {{ form|bootstrap }} + +
+
+
{% endblock %} diff --git a/nsupdate/accounts/views.py b/nsupdate/accounts/views.py index 23adef5..34b42f4 100644 --- a/nsupdate/accounts/views.py +++ b/nsupdate/accounts/views.py @@ -1,9 +1,22 @@ # -*- coding: utf-8 -*- -from django.views.generic import TemplateView +from django.views.generic import TemplateView, UpdateView +from django.contrib.auth.models import User +from django.core.urlresolvers import reverse + +from .forms import UserProfileForm -class UserProfileView(TemplateView): +class UserProfileView(UpdateView): template_name = "accounts/user_profile.html" + model = User + fields = ['first_name', 'last_name'] + form_class = UserProfileForm + + def get_object(self): + return self.request.user + + def get_success_url(self): + return reverse('account_profile') def get_context_data(self, *args, **kwargs): context = super(UserProfileView, self).get_context_data(*args, **kwargs)