I have an Event model (for an event like a concert or a play) that can have many Event_Dates (different showing dates and times of the concert of play). The model relation is implemented with a ForeignKey from the Event_Date model to the Event.
In the django admins, I have the Event_Dates included as an inline in the Event admin page. The inline code:
Pretty standard stuff based on what I know of django.
When the users of this application need to make a new Event that is an annual update of an event that is put on once each year (the Nutcracker, for instance - multiple performances every December), they go to last year's Event in the admin, check the "delete" checkbox next to all but one of the dates, then use the "Save as new" button to make a new Event.
This worked fine in django versions 1.2 through 1.6. A new event was created with one new date. In 1.7, when one does this, one gets the following error:
But in my case, while there is a signal associated with Event (on save, it looks up related Event Presenters, creates a string list of their names, then places that string in a field in the Event), it isn't anywhere in the stack trace for the error (below).
Initially, if anyone could help me figure out if this is a behavior that has changed in django versus one that might be related to my code, I'd appreciate it. I tried disabling all the signals in my application (there are 4 - I removed them from my code-base entirely, then rebooted the server to make sure apache and wsgi were looking at the current code) and the problem persisted.
I honestly was surprised that it used to work, am trying to figure out what to tell the user. For now, "Save as new" where one does not remove any Event_Dates works, so I advised the user to just do that, then update dates as needed in the new record.
Any help will be greatly appreciated.
Traceback:
File "/path/to/virtualenv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
584. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
204. return view(request, *args, **kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in change_view
1457. return self.changeform_view(request, object_id, form_url, extra_context)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
29. return bound_func(*args, **kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
25. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/db/transaction.py" in inner
394. return func(*args, **kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in changeform_view
File "/path/to/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view
1454. return self.changeform_view(request, None, form_url, extra_context)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
29. return bound_func(*args, **kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
25. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/db/transaction.py" in inner
394. return func(*args, **kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in changeform_view
1404. if all_valid(formsets) and form_validated:
File "/path/to/virtualenv/lib/python2.7/site-packages/django/forms/formsets.py" in all_valid
438. if not formset.is_valid():
File "/path/to/virtualenv/lib/python2.7/site-packages/django/forms/formsets.py" in is_valid
303. self.errors
File "/path/to/virtualenv/lib/python2.7/site-packages/django/forms/formsets.py" in errors
277. self.full_clean()
File "/path/to/virtualenv/lib/python2.7/site-packages/django/forms/formsets.py" in full_clean
343. self.clean()
File "/path/to/virtualenv/lib/python2.7/site-packages/django/forms/models.py" in clean
641. self.validate_unique()
File "/path/to/virtualenv/lib/python2.7/site-packages/django/forms/models.py" in validate_unique
648. valid_forms = [form for form in self.forms if form.is_valid() and form not in forms_to_delete]
File "/path/to/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in is_valid
1853. self.hand_clean_DELETE()
File "/path/to/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py" in hand_clean_DELETE
1833. collector.collect([self.instance])
File "/path/to/virtualenv/lib/python2.7/site-packages/django/contrib/admin/utils.py" in collect
180. return super(NestedObjects, self).collect(objs, source_attr=source_attr, **kwargs)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/db/models/deletion.py" in collect
168. reverse_dependency=reverse_dependency)
File "/path/to/virtualenv/lib/python2.7/site-packages/django/db/models/deletion.py" in add
85. if obj not in instances:
File "/path/to/virtualenv/lib/python2.7/site-packages/django/db/models/base.py" in __hash__
485. raise TypeError("Model instances without primary key value are unhashable")
Exception Type: TypeError at /path/to/event/edit/
Exception Value: Model instances without primary key value are unhashable