On Thu, 2009-01-08 at 09:56 +0100, Thomas Guettler wrote:
> Alvaro Mouriño schrieb:
> > 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.
> >
> >   
> Since a lot of users have this question/problem I added a patch to the
> documentation:
> 
> http://code.djangoproject.com/ticket/9987
> 
> +The method :class:`~django.contrib.auth.models.User.get_profile()`
> +does not create the profile, if it does not exist. You need to
> +register a handler for the signal
> +:attr:`django.db.models.signals.post_save` on the User model, and, in
> +the handler, if created=True, create the associated user profile.
> +

Good idea. We might need to tweak it to be clear about what exception is
raised when the profile doesn't exist (it's just a User.DoesNotExist
exception, right?), but that looks like the right idea.

Thanks, Thomas. You make a lot of those little cleanups and don't
necessarily get enough attention for it. They are appreciated.

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