Re: Userprofile, signal and admin inline edit.

2012-11-29 Thread Daniel Gerzo
Hello Jon,

have you ever found a solution for this? Thanks.

On Tuesday, June 14, 2011 5:04:09 PM UTC+2, Jon Biddle wrote:
>
> The issue seems to come from the fact that the order of operations 
> when you create the user looks like this: 
>
> 1) Django admin saves the new User 
> 2) post_save on User is triggered, and User's profile is created 
> 3) Django admin saves the UserProfile... but it already exists, and an 
> integrity error is raised 
>
>
> I'm currently looking into a solution to this as well, and will let 
> you know what I find. 
>
> On May 26, 8:39 am, Malcolm Box  wrote: 
> > On 26 May 2011 10:23, Jani Tiainen  wrote: 
> > 
> > > If I extend auth.User with custom profile and add automatic profile 
> > > creation signal it works as expected. 
> > 
> > > But if I try to add admin inline editor for profile when saving I get 
> > > exception about integration violation. 
> > 
> > > It happens because admin tries to create second profile for user when 
> > > saving. 
> > 
> > Have your signal handler check whether this is a creation of a user or 
> an 
> > edit. Only create the profile in the first case. 
> > 
> > You may also need to check whether the profile already exists before 
> trying 
> > to create - get_or_create() is your friend here. 
> > 
> > Malcolm

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/By34T_tvqpsJ.
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.



Re: Userprofile, signal and admin inline edit.

2011-06-14 Thread Jon Biddle
The issue seems to come from the fact that the order of operations
when you create the user looks like this:

1) Django admin saves the new User
2) post_save on User is triggered, and User's profile is created
3) Django admin saves the UserProfile... but it already exists, and an
integrity error is raised


I'm currently looking into a solution to this as well, and will let
you know what I find.

On May 26, 8:39 am, Malcolm Box  wrote:
> On 26 May 2011 10:23, Jani Tiainen  wrote:
>
> > If I extend auth.User with custom profile and add automatic profile
> > creation signal it works as expected.
>
> > But if I try to add admin inline editor for profile when saving I get
> > exception about integration violation.
>
> > It happens because admin tries to create second profile for user when
> > saving.
>
> Have your signal handler check whether this is a creation of a user or an
> edit. Only create the profile in the first case.
>
> You may also need to check whether the profile already exists before trying
> to create - get_or_create() is your friend here.
>
> 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.



Re: Userprofile, signal and admin inline edit.

2011-05-26 Thread Malcolm Box
On 26 May 2011 10:23, Jani Tiainen  wrote:

> If I extend auth.User with custom profile and add automatic profile
> creation signal it works as expected.
>
> But if I try to add admin inline editor for profile when saving I get
> exception about integration violation.
>
> It happens because admin tries to create second profile for user when
> saving.
>
>
Have your signal handler check whether this is a creation of a user or an
edit. Only create the profile in the first case.

You may also need to check whether the profile already exists before trying
to create - get_or_create() is your friend here.

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.



Userprofile, signal and admin inline edit.

2011-05-26 Thread Jani Tiainen
If I extend auth.User with custom profile and add automatic profile
creation signal it works as expected.

But if I try to add admin inline editor for profile when saving I get
exception about integration violation. 

It happens because admin tries to create second profile for user when
saving.

I can of course remove signal but that wouldn't create profile if I
insert user manually.

So how to make things work with both, admin inline profile editing and a
signal?

-- 

Jani Tiainen


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