Not quite sure, but it seems like the save() method is being called twice so it is trying to create insert an entry with a primary key that already exists.
On Thu, Sep 27, 2012 at 2:23 PM, enemybass <dominikan...@gmail.com> wrote: > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Thanks & Regards ---------------------------- Amyth [Admin - Techstricks] Email - aroras.offic...@gmail.com, ad...@techstricks.com Twitter - @mytharora http://techstricks.com/ -- 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.