[Fixed]-Trouble understaing User Object in Django

1👍

You are correct, the java perspective is the database perspective, which is true for django as well:

from django.contrib.auth.models import User

class Client(models.Model):

   user = models.OneToOneField(User)
   # ... more Client fields here

class Vendor(models.Model):

   user = models.OneToOneField(User)
   # ... more Vendor fields here

Note that these models allow a user to be a client and a vendor – or none at all. If a user can be only be a client or a vendor, or must be one of those classes, you will need additional validation. The User model will be used for the common features to all, such as authentication or other shared features (e.g. using the email to send a notification)

Leave a comment