Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CustomUser(AbstractUser):
- password = models.CharField(max_length=200, null=False)
- location = models.CharField(max_length=200, blank=True, default="")
- description = models.CharField(max_length=300, blank=True, default="")
- class CustomUserCreationForm(ModelForm):
- description = forms.CharField()
- location = forms.CharField()
- password1 = forms.CharField(label='Password', widget=forms.PasswordInput)
- password2 = forms.CharField(label='Password confirmation', widget=forms.PasswordInput)
- class Meta:
- model = CustomUser
- fields = ('username', 'email', 'password1', 'password2')
- class SignUpView(View):
- form_class = CustomUserCreationForm
- template_name = 'signup.html'
- def get(self, request):
- form = self.form_class()
- return render(request, self.template_name, {'form': form})
- def post(self, request):
- form = CustomUserCreationForm(request.POST)
- if form.is_valid():
- form.save(True)
- return render(request, self.template_name, {'form': form})
- class CustomUserAdmin(UserAdmin):
- fieldsets = UserAdmin.fieldsets + (('Misc', {'fields': ('description', 'location')}),)
- add_fieldsets = UserAdmin.add_fieldsets + (('Misc', {'fields': ('description', 'location')}),)
- admin.site.register(CustomUser, CustomUserAdmin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement