Thanks Simon
Those definitions are the closest I can get to the original in terms of type and relationship; what other info is needed?
That ticket refers to child models inline - not my situation.
Upgrading is on the cards - but still has to be budgeted for....
Derek
On 23 June 2016 at 21:26, Simon Charette <charette.s@gmail.com> wrote:
Hi Derek,--
It's hard to tell without your exact model admin definitions but I suspect this
might be related to #25987[1] which is fixed in Django 1.10.
By the way you should at least upgrade to 1.8 as your Django version is
not supported anymore and you could be exposed to multiple security issues.
Cheers,
Simon
[1] https://code.djangoproject.com/ticket/25987
Le jeudi 23 juin 2016 14:44:10 UTC-4, Derek a écrit :HiI have a strange situation (with Django 1.6.11 and MySQL 5.5). Attempting to save a new entry (from the admin) with values that violate the duplication restriction imposed by the unique_together constraint - in other words a duplicate of a record already in the database - raises an IntegrityError (stack trace listed at the end).The model looks like something like :name = CharField(max_length=100)title = ForeignKey(Title)city = CharField(max_length=50,default=CITY_DEFAULT),occupation = ForeignKey(Occupation)class Meta:ordering = ['name']unique_together = (('name', 'title', 'city', 'occupation', ),)I have also tested this situation in the shell. A normal clean() will not raise any error, but a full_clean() will. Does that imply the code path being triggered by an attempted save from within the admin does not call full_clean() or attempt to trap an IntegrityError?I should add that `city` field is not on the form to be filled in; and is added in the clean method.What is the best / correct solution to this?Thanks!DerekTraceback:File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response112. response = wrapped_callback(request, *callback_args, **callback_kwargs)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper465. return self.admin_site.admin_view(view)(*args, **kwargs)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view99. response = view_func(request, *args, **kwargs)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func52. response = view_func(request, *args, **kwargs)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner198. return view(request, *args, **kwargs)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper29. return bound_func(*args, **kwargs)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view99. response = view_func(request, *args, **kwargs)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func25. return func(self, *args2, **kwargs2)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/transaction.py" in inner371. return func(*args, **kwargs)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view1164. self.save_model(request, new_object, form, False)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in save_model893. obj.save()File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py" in save545. force_update=force_update, update_fields=update_fields)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py" in save_base573. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py" in _save_table654. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/base.py" in _do_insert687. using=using, raw=raw)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/manager.py" in _insert232. return insert_query(self.model, objs, fields, **kwargs)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/query.py" in insert_query1514. return query.get_compiler(using=using).execute_sql(return_id)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql903. cursor.execute(sql, params)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/backends/util.py" in execute69. return super(CursorDebugWrapper, self).execute(sql, params)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/backends/util.py" in execute53. return self.cursor.execute(sql, params)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/utils.py" in __exit__99. six.reraise(dj_exc_type, dj_exc_value, traceback)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/backends/util.py" in execute53. return self.cursor.execute(sql, params)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py" in execute124. return self.cursor.execute(query, args)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/MySQLdb/cursors.py" in execute205. self.errorhandler(self, exc, value)File "/home/derek/.virtualenvs/reg/local/lib/python2.7/site-packages/MySQLdb/connections.py" in defaulterrorhandler36. raise errorclass, errorvalueException Type: IntegrityError at /admin/collective/staff/add/Exception Value: (1062, "Duplicate entry 'Derek-4-london-7' for key 'name'")
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/MsJy7f7JUvU/unsubscribe.
To unsubscribe from this group and all its topics, 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/a589540b-c491-45c9-9d1c-ba47d7cef728%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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/CAF1Wu3OkdhBASo_wrW6YxM9eQx-A2Xcr0aQowLe%3DCFvrG3n7vg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment