6๐
You are most likely when Django packages which rely on Django 1.4-like models where User object always has an username
field. The issue is either in your own code or third party code, but the question does not has enough details to tell.
-
Use a full traceback to trace these addons
-
Update them if patched package is available
-
If there is no patch available you need to fork and patch the third party code yourself
About Django 1.5+ user model:
https://docs.djangoproject.com/en/stable/topics/auth/customizing/#auth-custom-user
You should most likely user id
to identify the user, not username
1๐
I had this problem too, what solved it was to use AbstractUser
instead of AbstractBaseUser
.
Then do a proper migrations so the database has the right attribute. Your code can be okay, but you will still have the error if your database is not up to date.
I say migration but it would probably be a lot easier (or the only way) to just destroy the db and start from scratch.
- [Django]-Django: filter queryset when 2 fields have same value
- [Django]-What is the difference between permission_classes and authentication_classes in django rest framework generic API Views
- [Django]-How can I set arbitrary attributes on Django Model Fields, then access them in a ModelForm?
- [Django]-How to secure files upload using django
0๐
AUTH_USER_MODEL = User
add a:
class User(AbstractBaseUser):
username = models.CharField(max_length=100)