Skip to content Skip to sidebar Skip to footer

User Signup Leads To Integrityerror

After a user signs up, the following IntegrityError is displayed: IntegrityError at /users/signup (1062, 'Duplicate entry '1' for key 2') Even though the user gets an error, he ca

Solution 1:

I'm going to take a guess and suggest it could be your post_save signal being registered multiple times as a result of the models.py being loaded more than once. You aren't registering your signal in a safe manner. Maybe its trying to create the profile more than once rapidly on save() and getting the error.

Take a look at the docs on Preventing Duplicate Signals

Try changing the last line to something like:

post_save.connect(create_user_profile, sender=User, 
                    dispatch_uid="user_create_profile")

Having the dispatch uid will cause it only to be registered once, even if its called many times as a result of imports.

Post a Comment for "User Signup Leads To Integrityerror"