My project is simple blog app where users can post,comment and like posts. I used Django default user registration page, later I add Djoser (third party token authentication for Django rest framework) with custom user model, it result in crash, please look into this
please note that if I avoid custom user for Djoser,my project works fine,ie I am able to register using token and session authentication
FORMS.PY #for Django's default register view
from django import forms
#from django.contrib.auth.models import User
from .models import User
from django.contrib.auth.forms import UserCreationForm
class UserRegisterForm(UserCreationForm):
email = forms.EmailField()
class Meta:
model = User
fields=['username','email','phone','first_name','last_name','password1','password2']
MODELS.PY # Djoser Custom user model
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.conf import settings
class User(AbstractUser):
email = models.EmailField(verbose_name='email' ,max_length=223,unique=True)
phone=models.CharField(null=True,max_length=11)
REQUIRED_FIELDS = ['username','phone','first_name','last_name']
#USERNAME_FIELD = 'email'
def get_username(self):
return self.email
ERROR TRACEBACK
ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
userapp.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
userapp.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.