In that case I suggest you create multiple models, one for each type of user. For example, you could have a SupplierProfile, DesignerProfile, etc...
The reason I suggest multiple profile models, instead of just one model with a configurable account type field, is that I assume each of these user types will have it's own data. For example the SupplierProfile might need a bank account details field, whereas a designer probably does not. So create multiple models, named similar to SupplierProfile, DesignerProfile, etc and have each of those link to the Django user model via a OneToOne key. This is similar to what you're doing with your UserDetails models. Hope that helps. Asad Jibran Ahmed <[email protected]> http://blog.asadjb.com On Mon, Oct 24, 2016 at 7:18 AM, Shazia Nusrat <[email protected]> wrote: > I've deleted DB and migrations I had previously. > But still can't figure this out. What I need is....that multiple shops > needs to get registered with my ecommerce store as well as designers and as > well as referrers to sell products and then simple registration while > checkout is in progress. > > I have simple idea that I need to somehow create submodel from built-in > User model with abstract model. Then I want that if user selects Customer > then customer form should appear, if user says Designer it should present > designer and so on except the checkout user that I figured out to complete > the order with guest user by catching session ID and user's email upon > checkout. > > This part I can't figure out. Moreover all these account should have > access to relevant content. Like Supplier should be able to manage > inventory or his/her products. Designer only should sell their products in > bulk etc. So if I fix this issue then I can move forward otherwise its a > dead lock for me from 4 last hours. > > Please advise. > > Regards, > > Shazia > > On Sun, Oct 23, 2016 at 7:53 PM, Asad Jibran Ahmed <[email protected]> > wrote: > >> 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 <[email protected]> >> http://blog.asadjb.com >> >> On Mon, Oct 24, 2016 at 4:37 AM, Shazia Nusrat <[email protected]> >> 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 [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/group/django-users. >>> To view this discussion on the web visit https://groups.google.com/d/ms >>> gid/django-users/CAD83tOxKnQCeWyWjYmbxo7iaxmsysk8WJs-zy44GZb >>> DXr93iEg%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 [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit https://groups.google.com/d/ms >> gid/django-users/CA%2BYYaWfEdFhBjv0M%2BC3XApq1z2-k1tGG6orwwD >> dcOwn2JezOrw%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CA%2BYYaWfEdFhBjv0M%2BC3XApq1z2-k1tGG6orwwDdcOwn2JezOrw%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 [email protected]. > To post to this group, send email to [email protected]. > 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/CAD83tOwAv485tsY%3D5NLnXK2N% > 2BOwY%2Bj5aQXy9Dk_nTdJupJPm9g%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAD83tOwAv485tsY%3D5NLnXK2N%2BOwY%2Bj5aQXy9Dk_nTdJupJPm9g%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 [email protected]. To post to this group, send email to [email protected]. 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%2BYYaWft0XDYVg-2UPca%3D4gMjgOYRM02bnMcXxgmCkg6RVt18w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

