from django import forms from .models import * class RegistrationForm(forms.ModelForm): class Meta: model = CustomUser fields = ['username', 'first_name', 'last_name', 'email', 'password', 'photo_profile'] def save(self, commit=True): user = super(RegistrationForm, self).save(commit=False) user.set_password(self.cleaned_data['password']) if commit: user.save() return user