In my Django project (which is a REST API) I'm having a problem that has probably been encountered before yet I can't find a good solution to it anywhere. In my project I have 2 different kinds of users, "Mobile app users" and "Business users". The mobile app users can go into our mobile app and see content around them based on geolocation. The business users can log on to a web admin portal and generate the content that the mobile app user sees. As a caveat there is also the possibility that a business user can also be an app user. I want to be able to allow a business user and an app user to have the same email while still having it be unique to their model.
Now Problem is how It is possible to create a two account(1st is mobile app & 2nd is business) with same Email ID..
No matter what strategy you pick, or what is your business model, always use one, and only one Django model to handle the authentication. You can still have multiple user types, but generally speaking it's a bad idea to store authentication information across multiple models/tables.
Django allows you to override the default user model by providing a value for the AUTH_USER_MODEL setting that references a custom model. Method 2 – AUTH_USER_MODEL : AUTH_USER_MODEL is the recommended approach when referring to a user model in a models.py file.
Groups: Way of Categorizing UsersDjango provides a basic view in the admin to create these groups and manage the permissions. The group denotes the “role” of the user in the system. As an “admin”, you may belong to a group called “admin”. As a “support staff”, you would belong to a group called “support”.
Initially, there are two types of users in a Django application: superuser accounts and regular users. Superusers have every attribute and privilege of regular accounts, but also have access to the Django admin panel, a powerful application that we'll explore in detail in a future article.
There is a few possible solutions to deal with different type of users. According to your situation you should. This article covers the subject in many ways: How to Implement Multiple User Types with Django
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With