The following is all I could find in the docs about ModelAdmin.save_as

ModelAdmin.save_as (https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_as)

    Set save_as to enable a “save as” feature on admin change forms.

Normally, objects have three save options: “Save”, “Save and continue editing” and “Save and add another”. If save_as is True, “Save and add another” will be replaced by a “Save as” button.

“Save as” means the object will be saved as a new object (with a new ID), rather than the old object.

    By default, save_as is set to False.



I'm having problems with [save as new] when the model has inlines. Is there a known gotcha in this area?

The particular error I'm seeing is ...



IntegrityError at /admin/substance/substance/20/

duplicate key value violates unique constraint "substance_liquid_substance_id_key"
DETAIL:  Key (substance_id)=(54) already exists.

Request Method:         POST
Request URL:    http://localhost:8000/admin/substance/substance/20/
Django Version:         1.7.8
Exception Type:         IntegrityError
Exception Value:        

duplicate key value violates unique constraint "substance_liquid_substance_id_key"
DETAIL:  Key (substance_id)=(54) already exists.

Exception Location: C:\Users\mike\env\xxex3\lib\site-packages\django\db\backends\utils.py in execute, line 65
Python Executable:      C:\Users\mike\env\xxex3\Scripts\python.exe
Python Version:         3.4.3
Python Path:    

['/var/www/ssds',
 'C:\\Users\\mike\\env\\xxex3\\ssds',

'C:\\Users\\mike\\env\\xxex3\\lib\\site-packages\\psycopg2-2.5.4-py3.4-win32.egg',

'C:\\Users\\mike\\env\\xxex3\\lib\\site-packages\\pillow-2.7.0-py3.4-win32.egg',
 'C:\\WINDOWS\\SYSTEM32\\python34.zip',
 'C:\\Users\\mike\\env\\xxex3\\DLLs',
 'C:\\Users\\mike\\env\\xxex3\\lib',
 'C:\\Users\\mike\\env\\xxex3\\Scripts',
 'C:\\Python34\\Lib',
 'C:\\Python34\\DLLs',
 'C:\\Users\\mike\\env\\xxex3',
 'C:\\Users\\mike\\env\\xxex3\\lib\\site-packages',
 'C:/Users/mike/env/xxex3/ssds']

Server time:    Tue, 23 Jun 2015 12:08:44 +1000


The relationship between substance and liquid is 1:1 and the error is highlighted in my liquid.save() method. However, when I comment that whole save() method out and try [save as new] again the error doesn't change, just the substance pk which increments from 54 (as above) to 55 and none of my code seems to be involved. Or at least the traceback doesn't highlight any.

There appear to be no problems with the code saving normally and there are hundreds of unit tests all passing successfully.

I would really appreciate any help. Is there more info I can provide?

Python 3.4 (Windows 8.1)
Django 1.7.8 (Windows 8.1)
Postgres 9.1 (Ubuntu 12.04)

Thanks for any hints.

Mike

--
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5588CAFF.3070807%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to