开发者

Django: What's the best way to create different "kinds" of users and use them interchangeably?

开发者 https://www.devze.com 2023-04-08 00:58 出处:网络
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

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开发者_JS百科 Classes (Seller and Buyer) becouse they can have different data.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消