Thursday, September 27, 2012

IntegrityError at /add/ PRIMARY KEY must be unique

 http://wklej.org/id/837631/ - models, traceback, urls, views, database structure


After adding data to database I have error (data is added correctly but displays an error):


Exception Type: IntegrityError at /add/  Exception Value: PRIMARY KEY must be unique

def add(request):  	if request.user.is_authenticated():  		user = request.user     		b = Product.objects.get(id=3)     		e = b.basket_set.create(name='basket_name', owner=user)      	e.save(force_insert=True)  	  	return render_to_response('basket.html')

How to fix it?

--
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/-/mdIBvzeje1gJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment