title: Edit user profiles form without using django admin
body: <p>I am developing a simple LMS system where I have 3 stakeholders Administrator, Faculty Members and Students. Administrator can create, edit, delete, block and list user accounts, with my developement so far I am able to create and list all users.</p>
  
  <p>Now I am stuck at editing user profile, my requirement is when I click on any listed users it should open my extended/customized user profile in a form and I should have the ability to edit any opened user profile.</p>
  
  <p>Below are my code snippets:</p>
  
  <p>MODELS.PY:</p>
  
  <pre><code>from django.contrib.auth.models import User
  class UserInformation(models.Model):
      user = models.ForeignKey(User, unique=True)
      degree = models.ForeignKey(Degree, null=True, blank=True)
      stakeholder = models.ForeignKey(Stakeholder)
      cell_number = models.CharField(max_length=32, null=True, blank=True)
  
      def __str__(self):
          return self.user.username
  </code></pre>
  
  <p>VIEWS.PY (to create user):</p>
  
  <pre><code>def ad_create_user(request):
      if request.method == 'POST':
          firstname = request.POST['firstname']
          lastname = request.POST['lastname']
          username = request.POST['username']
          password = request.POST['password']
          email = request.POST['email']
          group = request.POST['group']
          degree = request.POST['degree']
          cell_no = request.POST['cell_no']
          new_user = User.objects.create_user(username, email, password)
          new_user.first_name = firstname
          new_user.last_name = lastname
          new_user.save()
  
          if group == 'option_one':
              set_group = 3
              new_user.groups.add(3)
              userinfo = UserInformation(user=User.objects.get(username=username), degree=Degree.objects.get(pk=degree),
                                         stakeholder=Stakeholder.objects.get(pk=set_group), cell_number=cell_no)
              userinfo.save()
          if group == 'option_two':
              set_group = 2
              new_user.groups.add(2)
              userinfo = UserInformation(user=User.objects.get(username=username),
                                         stakeholder=Stakeholder.objects.get(pk=set_group), cell_number=cell_no)
              userinfo.save()
          if group == 'option_three':
              set_group = 1
              new_user.groups.add(1)
              userinfo = UserInformation(user=User.objects.get(username=username),
                                         stakeholder=Stakeholder.objects.get(pk=set_group), cell_number=cell_no)
              userinfo.save()
          return HttpResponseRedirect('/administrator/user_management/')
      return render(request, 'MobiApp/create_user.html', {'form': CreateUserForm()})
  </code></pre>
  
  <p>FORMS.PY (to create user):</p>
  
  <pre><code>class CreateUserForm(forms.Form):
      firstname = forms.CharField(max_length=64)
      lastname = forms.CharField(max_length=64)
      username = forms.CharField(max_length=16)
      password = forms.CharField(
          widget=forms.PasswordInput(),
      )
      email = forms.EmailField()
      group = forms.ChoiceField(
          choices=(
              ('option_one', "Student"),
              ('option_two', "Faculty Member"),
              ('option_three', "Administrator"),
          ),
          widget = forms.RadioSelect,
          initial = 'option_one',
      )
      degree = forms.ModelChoiceField(queryset=Degree.objects.all())
      cell_no = forms.CharField()
  
      helper = FormHelper()
      helper.form_class = 'form-horizontal'
      helper.layout = Layout(
          Field('firstname', css_class='input-xlarge'),
          Field('lastname', css_class='input-xlarge'),
          Field('username', css_class='input-xlarge'),
          Field('password', css_class='input-xlarge'),
          Field('email', css_class='input-xlarge'),
          'group',
          'degree',
          Field('cell_no', css_class='input-xlarge'),
          FormActions(
              Submit('create', 'Create!', css_class="btn-primary"),
          )
      )
  </code></pre>
  
  <p>I found many questions similar to this but none of them helped me and my requirement is also little different as user is not editing his/her profile but administrator is editing profile of any user.</p>
  
  <p>Just for your information:</p>
  
  <ul>
  <li><p>I am using Django-Crispy-Forms</p></li>
  <li><p>When I click on any user of edit profile, its URL will be something like this <a href="http://myapp.com/administrator/edit_user/11" rel="nofollow">http://myapp.com/administrator/edit_user/11</a></p></li>
  </ul>
  
  <p>where 11 is the user id</p>
  
  <p>Thanks in advance, let me know if you need any further information.</p>