Thursday, May 25, 2017

Re: saving data from both a model and a derived model



On Wed, May 24, 2017 at 11:03 AM, Jim Anderson <jjanderson52000@gmail.com> wrote:
Hi James,

I'm attaching the stacktrace as you requested.


Thanks. It is quite telling:

  File "/home/jja/testenv3.5/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 337, in execute      return Database.Cursor.execute(self, query, params)  django.db.utils.IntegrityError: UNIQUE constraint failed: siggy_stemplate.name

The object you are working with is having a 'name' clash with another object of the same type. You've set the 'name' field to be unique, so you'll need to ensure that each object has a unique value for the 'name' field. Either check for uniqueness before assigning it, or attempt to save, catch this exception, and generate a more unique value as needed, rinse and repeat as necessary.

-James

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXe1xbw0F9su1RsVbbN_jeGhFynzLjGExL%3DiSAwT45svw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment