Simplest solution : don't worry about the AUTH_PROFILE_MODULE setting.

I'm working on a site with numerous modules that contain user account 
information, such as orders and newsletter preferences. I just have a 
foreignkey to the auth User on each of these, eg:

class OrderAccount(models.Model):
    user = models.ForeignKey(User,related_name="order_account")
 
class NewsletterAccount(models.Model):
    user = models.ForeignKey(User,related_name="newsletter_account")

Then, when you're interacting with a user model you can get any of your 
account models with user.order_account or user.newsletter_account.

Regards,
Andrew Ingram

Gok Mop wrote:
> I'm struggling with how to design something, and I'm pretty sure
> somebody has an easy solution.
>
> I need to store different information about different classes of
> users.  I want to attach those classes as the user profile to my
> django.contrib.auth.User object, so I can always cross-walk from the
> User object to my profile object, and vice versa.  The trouble is that
> I have more than 1 profile object.
>
> My multiple profile objects share a common superclass:
>
> class MyPerson(models.Model):
>     user = models.ForeignKey(User, unique=True)
>     (...handful of other things...)
>
> (In settings, I specify AUTH_PROFILE_MODULE="myapp.myperson")
>
> I then have 4-5 objects that extend MyPerson and tack on all the stuff
> specific to that object.
>
> When I create users and associate profiles, that works great.  When I
> 'restore' a user from the database and ask for the profile, I get a
> MyPerson object, and I've lost the linkage to my subclass...and I'm up
> a river.  Particularly since I need some of the subclass information
> and methods in order to make access decisions for the User.
>
> Suggestions?  Any pointers would be very helpful.
> Thanks
>   

--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to