On Feb 19, 6:39 pm, Andrew Ingram <a...@andrewingram.net> wrote:
> 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")

Sounds like a good idea...thanks.

> 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.

This is the part that I'm not sure about though.  So let's say I have
4 objects that all take this same approach.  (Call them foo, bar, baz,
and quux).  Then one of my views gets a user object, and needs to
figure out which attached object is relevant.  (There's only one
possibility).  Does that mean that I have to do:

myobj = user.foo_account
if myobj == None: myobj = user.bar_account
if myobj == None: myobj = user.baz_account
if myobj == None: myobj = user.quux_account

?

In short, how do I tell which field I should be accessing?  Only one
will be non-None.



--~--~---------~--~----~------------~-------~--~----~
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