Modifying Django UserCreationForm -
Modifying Django UserCreationForm -
i wanted add together more fields standard django usercreationform went ahead , subclassed within of app's forms.py file , ended this:
class customusercreationform(usercreationform): email = forms.emailfield(label = "email") first_name = forms.charfield(label = "first name") last_name = forms.charfield(label = "last name") class meta: model = user fields = ("first_name", "last_name", "username",) def save(self, commit=true): user = super(customusercreationform, self).save(commit=false) user.first_name = first_name user.last_name = last_name user.email = self.cleaned_data["email"] if commit: user.save() homecoming user
i went ahead , created custom modeladmin users, looks this:
class customuseradmin(useradmin): add_form = customusercreationform inlines = [profileinline,] admin.site.unregister(user) admin.site.register(user, customuseradmin) admin.site.register(class, classadmin)
no matter do, however, new customusercreationform not show when go admin page , seek add together new user. screwing up?
edit: seems form not beingness displayed, beingness used. if seek add together new user using username , password fields typical usercreationform has, error, promptly goes away when remove add_form line in modeladmin. why not displaying?
i not have admin templates in local app directory. issue?
you'll need add together fields you've added add_fieldsets property of custom user admin class.
#example: add_fieldsets = ( (none, { 'classes': ('wide',), 'fields': ('username', 'email', 'password1', 'password2')} ), )
a user had similar question other day: how can have django user registration single step (instead of 2 step)process email compulsory? involved creating custom user admin form well.
django django-admin django-authentication
Comments
Post a Comment