Did you change the AUTH_USER_MODEL setting *after *you had already run python
manage.py migrate once (or more) before? From the error I guess what's
happening is that you already have a User model in place. It was probably
created when you first ran Django migrations without specifying a custom
user model.

If that is the case, and you *really *want a custom user model, you'll have
to ensure that the user model is the first model create in your app. For
details look at the warning given at
https://docs.djangoproject.com/en/1.10/topics/auth/customizing/#substituting-a-custom-user-model
.

>From what I'm seeing of your models, you only seem to want to add extra
fields to each user. You can also do that by just pointing your UserDetails
model to the existing django.contrib.auth.models.User model, and adding the
type information in your UserDetails model instead. That might work for
you. Otherwise you'll have to remove your existing database and run
migrations from start.

Asad Jibran Ahmed <surfer...@gmail.com>
http://blog.asadjb.com

On Mon, Oct 24, 2016 at 4:37 AM, Shazia Nusrat <shazianu...@gmail.com>
wrote:

> Hi,
> I am trying to create multiple types of users in my django e-commerce
> project by extending built-in Django user model but I am having issue.
>
> Would appreciate if someone can guide me to right direction.
> Following is the code in my "accounts" app.
>
> from __future__ import unicode_literals
> from django.db import models
> from django.contrib.auth.models import AbstractUser
>
> class CustomUser(AbstractUser):
>     type_choices = (
>         ('Supplier', 'Supplier'),
>         ('Designer', 'Designer'),
>         ('Shop', 'Shop'),
>         ('Referrer', 'Referrer'),
>         ('User', 'User'),
>     )
>     user_type = models.CharField(max_length=2,
>                                  choices=type_choices,
>                                  default='User')
>
> class UserDetails(models.Model):
>     type = models.OneToOneField(CustomUser)
>     extra_info = models.CharField(max_length=200)
>
> My settings.py includes 'accounts' in installed app and variable included
> for extending models in settings.py:
>
> AUTH_USER_MODEL = 'accounts.Customer'
>
> Error:
>
>
> ERRORS:
> accounts.CustomUser.groups: (fields.E304) Reverse accessor for
> 'CustomUser.group
> s' clashes with reverse accessor for 'User.groups'.
>         HINT: Add or change a related_name argument to the definition for
> 'Custo
> mUser.groups' or 'User.groups'.
> accounts.CustomUser.user_permissions: (fields.E304) Reverse accessor for
> 'Custom
> User.user_permissions' clashes with reverse accessor for
> 'User.user_permissions'
> .
>         HINT: Add or change a related_name argument to the definition for
> 'Custo
> mUser.user_permissions' or 'User.user_permissions'.
> auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes
> with
> reverse accessor for 'CustomUser.groups'.
>         HINT: Add or change a related_name argument to the definition for
> 'User.
> groups' or 'CustomUser.groups'.
> auth.User.user_permissions: (fields.E304) Reverse accessor for
> 'User.user_permis
> sions' clashes with reverse accessor for 'CustomUser.user_permissions'.
>         HINT: Add or change a related_name argument to the definition for
> 'User.
> user_permissions' or 'CustomUser.user_permissions'.
>
> Please advise.
>
> Regards,
> Shazia
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAD83tOxKnQCeWyWjYmbxo7iaxmsys
> k8WJs-zy44GZbDXr93iEg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAD83tOxKnQCeWyWjYmbxo7iaxmsysk8WJs-zy44GZbDXr93iEg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BYYaWfEdFhBjv0M%2BC3XApq1z2-k1tGG6orwwDdcOwn2JezOrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to