Question

I'm developing an SAAS and having the hardest time wrapping my brain around why I need to use "User" for anything other than myself. I don't know why but it makes me queezy to think that I, as the developer/admin of the entire software, with full Django Admin access (like the Eye of Sauron), have the same type of User object as an "Account" holder's "UserProfile" has. Please help me understand why this is necessary.

Example:

class Account(models.Model): # represents copporate customer
    admin = models.ForeignKey(User)
    # other fields ...

class UserProfile(models.Model):
    user = models.ForeignKey(User)
    account = models.ForeignKey(Account)

It feels like I'm mingling the builtin Admin functionality with my account holders' users' functionality. Is this just for purposes of reusing elements like request.user, etc.?

Was it helpful?

Solution

Well, reuse of code and functionality might be a happy side-effect, but fundamentally I don't think this is broken.

A User represents someone using your website. At the base level it doesn't matter who that person is or what features or functionality they need - just that they make requests and can be identified in some way.

Further functionality can be added in different layers, either through built in components like Groups or Permissions, or through something else you build on top yourself as you are doing in your example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top