A
A
amal_muslim2018-06-12 15:05:59
Django
amal_muslim, 2018-06-12 15:05:59

How to create two kinds of users in a Django site?

I have a Django site, and a custom User model inherited from AbstractUser , but I need to make two types of users, a seller and a buyer. The buyer has nothing but to select a product and add to favorites, but the seller has the city where he lives, the product he sells, the type of product. How to create two different users on the site during registration and how to store it in the database

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Roman Kitaev, 2018-06-12
@deliro

role=CharField(choices=...)

E
Eugene, 2018-06-12
@immaculate

You can simply create two groups: seller and buyer. When registering, add the user to the appropriate group. Create/assign groups the permissions you want or use django-rules. Whether in views to check there are the necessary permissions.

K
KhD, 2018-06-21
@KhD

Read https://habr.com/post/313764/ , look towards the second strategy of the article for creating and storing sellers in the database + you can add a boolean field of type is_seller to the user model.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question