On Wed, 2009-01-07 at 22:50 -0200, Alvaro Mouriño wrote:
> I find myself checking for the existence of the profile object for the
> user everytime I call the get_profile function or making sure that it
> gets created with every user.
> 
> Is there a reason for this? Shouldn't the framework assure me that I
> will get a profile whenever I call get_profile()? Even if it means
> creating one?

The function is called get_profile, not get_or_create_profile.

Some people would like it to create automatically, others prefer it to
be explicit. I'm in the latter camp: if a user should have a profile, I
should create it properly when creating the user (e.g. using a signal),
not have some magical transparency happen behind the curtain that hides
the bug of me forgetting to do so. After all, if you're creating a
profile, you might well need to initialise it in some particular default
way. So now get_profile() needs to be like get_or_create() and accept a
bunch of default arguments. Much more complicated.

It's a moot point, though. Changing it would introduce the sort of
backwards incompatibility we try to avoid.

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

Reply via email to