fix: Correctly use custom user model in registration form

This commit is contained in:
moanos [he/him] 2024-04-07 11:41:37 +02:00
parent 0d22ea0b65
commit 1a2878330e
2 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,5 @@
from django import forms from django import forms
from .models import AdoptionNotice, Animal, Image, Report, ModerationAction from .models import AdoptionNotice, Animal, Image, Report, ModerationAction, User
from django_registration.forms import RegistrationForm from django_registration.forms import RegistrationForm
@ -45,4 +45,5 @@ class ModerationActionForm(forms.ModelForm):
class CustomRegistrationForm(RegistrationForm): class CustomRegistrationForm(RegistrationForm):
pass class Meta(RegistrationForm.Meta):
model = User

View File

@ -1,4 +1,7 @@
from django.urls import path, include from django.urls import path, include
from django_registration.backends.activation.views import RegistrationView
from .forms import CustomRegistrationForm
from . import views from . import views
@ -35,6 +38,12 @@ urlpatterns = [
# ex: user/1 # ex: user/1
path("user/<int:user_id>/", views.member_detail, name="user-detail"), path("user/<int:user_id>/", views.member_detail, name="user-detail"),
path('accounts/register/',
RegistrationView.as_view(
form_class=CustomRegistrationForm
),
name='django_registration_register',
),
path('accounts/', include('django_registration.backends.activation.urls')), path('accounts/', include('django_registration.backends.activation.urls')),
path('accounts/', include('django.contrib.auth.urls')), path('accounts/', include('django.contrib.auth.urls')),