0
votes

I'm building a site similar to eBay. I have two kind of users: Sellers and Buyers.

I've read this https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional-information-about-users and i've created a UserProfile(abstract) model and two other models: Seller and Buyer.

Now, i've other model: Comment. Comment can be wrote by Sellers and Buyers. How should i relate them? I've been thinking these options, but i have no expirience with Django and maybe you have a better idea:

class Comment(models.Model):
   created_by =  models.ForeignKey(UserProfile)

or

class Comment(models.Model):
   created_by = models.ForeignKey(auth.models.User)

EDIT:

I want to have different Classes (Seller and Buyer) becouse they can have different data.

1

1 Answers

1
votes

Groups. It's already part of Django authentication.

https://docs.djangoproject.com/en/1.3/topics/auth/#groups

How should [I] relate them?

Relate to the User. You get the profile from the User. You get the groups from the User.

Relate to the primary, central, important entity. Think of a Profile as an add-on thing.