# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.contrib import admin
from .models import User

# Register your models here.
admin.site.register(User)

@@ -58,16 +58,41 @@
 terals%0A%0A
+from django import forms%0A
 from dja
@@ -116,16 +116,174 @@
 t admin%0A
+from django.contrib.auth.admin import UserAdmin as Admin%0Afrom django.contrib.auth.forms import UserCreationForm%0Afrom django.contrib.auth.models import Group%0A%0A
 from .mo
@@ -304,59 +304,1072 @@
 er%0A%0A
-#
+%0Aclass
  Regist
-er your models here.%0Aadmin.site.register(User
+rationForm(UserCreationForm):%0A%0A    %22%22%22A form for user creation.%0A%0A    Email, username, password and role are given.%0A    %22%22%22%0A%0A    email = forms.EmailField(required=True)%0A%0A%0A    class Meta:%0A%0A        %22%22%22Give some options (metadata) attached to the form.%22%22%22%0A%0A        model = User%0A        fields = ('role',)%0A%0A%0A    def save(self, commit=True):%0A        user = super(RegistrationForm, self).save(commit=False)%0A        user.email = self.cleaned_data%5B'email'%5D%0A        user.role = self.cleaned_data%5B'role'%5D%0A        user.set_is_staff(user.role)%0A        if commit:%0A            user.save()%0A        return user%0A%0A%0Aclass UserAdmin(Admin):%0A%0A    %22%22%22Represent a model in the admin interface.%22%22%22%0A%0A    add_form = RegistrationForm%0A%0A    # add_fieldsets is not a standard ModelAdmin attribute. UserAdmin%0A    # overrides get_fieldsets to use this attribute when creating a user.%0A    add_fieldsets = (%0A        (None, %7B%0A            'fields': ('email', 'username', 'password1', 'password2', 'role')%7D%0A         ),%0A    )%0A%0A%0Aadmin.site.register(User, UserAdmin)%0Aadmin.site.unregister(Group
 )%0A

Add form for user creation