Opened 12 years ago

Closed 12 years ago

#19603 closed Uncategorized (invalid)

Custom User model called "User" causes errors

Reported by: berto Owned by: nobody
Component: Uncategorized Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I tried creating a custom User model called User subclassing AbstractUser and ended up with m2m errors:

[berto@g6]$ python manage.py syncdb --noinput
CommandError: One or more models did not validate:
someapp.user: Accessor for m2m field 'groups' clashes with related m2m
field 'Group.user_set'. Add a related_name argument to the definition
for 'groups'.
someapp.user: Accessor for m2m field 'user_permissions' clashes with
related m2m field 'Permission.user_set'. Add a related_name argument to
the definition for 'user_permissions'.
auth.user: Accessor for m2m field 'groups' clashes with related m2m
field 'Group.user_set'. Add a related_name argument to the definition
for 'groups'.
auth.user: Accessor for m2m field 'user_permissions' clashes with
related m2m field 'Permission.user_set'. Add a related_name argument to
the definition for 'user_permissions'.

I have an example of this problem here:

https://github.com/rca-archive/django_custom_user_model_called_user/commit/ab23eefbe7d0eccb77a73a7598c3d41f9f6bfa1e

and it subsequently working by renaming the model here:

https://github.com/rca-archive/django_custom_user_model_called_user/commit/88f034fd35281beecf77db427845eff4da3e1ce9

If there is a reason that a custom User model has to be called something other than User, it would be great to mention that in the docs:

https://docs.djangoproject.com/en/dev/topics/auth/customizing/#substituting-a-custom-user-model

Thanks!

Change History (1)

comment:1 by Preston Holmes, 12 years ago

Resolution: invalid
Status: newclosed

Here is the typo causing your problem:

https://github.com/rca-archive/django_custom_user_model_called_user/blob/ab23eefbe7d0eccb77a73a7598c3d41f9f6bfa1e/customuser/settings.py#L6

you wanted AUTH_USER_MODEL instead of AUTH_USER_MODULE

Note: See TracTickets for help on using tickets.
Back to Top