i'm new with django. I've something to ask you.
I'm building a website similar to eBay where i've different "kinds" of
users. These are: CustomerUser and SellerUser. Both of them has
different data to be saved.
While reading docs and django book i noted the UserProfile
"trick" (https://docs.djangoproject.com/en/1.3/topics/auth/#storing-
additional-information-about-users) to store additional info about my
users. The problem is that i've two different users, not just one.
I'm wondering what would be the best choice. I've think that i could
use some inheritance, keeping the UserProfile strategy.
class UserProfile(models.Model):
# some common data
user = models.OneToOneField(User)
class Seller(UserProfile):
#specific Seller data
class Customer(UserProfile):
#specific Customer data
I tried to make that work, but i coulnd. I ran into several errors.
After that i thought i could include oneToOne info in the UserProfile,
similiar to:
class UserProfile(models.Model):
is_seller = models.BooleanField()
is_customer = models.BooleanField()
seller_info = models.OneToOneField(SellerInfo)
customer_info = models.OneToOneField(CustomerInfo)
user = models.OneToOneField(User)
class SellerInfo(models.Model):
#specific Seller data
class CustomerInfo(models.Model):
#specific Customer data
I think this should work, but also think that would be a "weird and
ugly" solution.
Have you expirienced this kind of problem? Can you help me with some
idea please?
Thank you very much!
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment