So the solution you recommend, "Have the foreign key point to the auth.User model and then use person.get_profile() if you need to access the profile object"... is that a "best practice" for dealing with users and profiles? Never link directly to the profile and always to the user?
On May 4, 4:32 pm, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > On Mon, 2009-05-04 at 12:51 -0700, eric.frederich wrote: > > Thanks for the reply. > > > You're right that auth.User is not a replacement for a profile. > > Maybe I will make the training app require only that a profile model > > exists and has a particular set of fields like cost-center, manager's > > e-mail, etc. > > This way at least it wouldn't be tied to a particular implementation > > of a profile. > > > I would just have things like... > > > class Enrollment(models.Model): > > person = models.ForeignKey(settings.AUTH_PROFILE_MODULE) > > offering = models.ForeignKey(Offering) > > > If I do this, then do I run into that problem of not being able to > > import the models file? > > I probably wasn't clear about the issue with importing the models file. > As you've written things, Python needs to accessing > settings.AUTH_PROFILE_MODULE in order to parse the class definition. > That is, it needs to access settings at import time. This has two > implications: > > (1) Once you have accessed settings, you really shouldn't change them. > So code importing that file should do so after making sure the settings > are as they want them. > > (2) If somebody is using explicit settings configuration via > django.conf.settings.configure(), they would have to call configure() > *prior* to importing the above file, otherwise the settings might well > not exist yet (and, if they do, they'll contain the wrong values). Code > tends to look neater if you can put all your imports at the top and then > have you executable lines -- including calling settings.configure() -- > later on. The above fragment prevents that. Not insurmountable, but not > as neat as possible. > > Now, to be practical, in 90%+ of the time, these probably aren't issues. > You'll be using DJANGO_SETTINGS_MODULE or something similar to do the > "normal" settings process. > > All that being said, there's a fairly simple solution here. Have the > foreign key point to the auth.User model and then use > person.get_profile() if you need to access the profile object. > > Regards, > Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---