Error UNIQUE constraint failed with Django 1.7

217 views
Skip to first unread message

cristian jimenez

unread,
Sep 22, 2014, 12:23:44 PM9/22/14
to django...@googlegroups.com
I got error (Error UNIQUE constraint failed) when tried create an object with create function. Many websites post the solution is update sequence of database, but the problem isn't solved. I had this code:

TutorUser.objects.create(
            user
=user,
            birthdate
=date_obj,
            name
=request.POST['name'],
            usertype
="tutor")



I solved the problem, changing to this:

tu = TutorUser(
            user
=user,
            birthdate
=date_obj,
            name
=request.POST['name'],
            usertype
="tutor")
tu
.save()



The question is ... ¿is that a bug of Django 1.7?



Collin Anderson

unread,
Sep 23, 2014, 8:21:36 AM9/23/14
to django...@googlegroups.com
Hmm... That should be the same. I think the only difference is create() might use force_insert=True. Do you have a custom save() method?
Reply all
Reply to author
Forward
0 new messages