#18864: Django models __eq__ and __hash__ treat all unsaved model instances as identical -------------------------------------+------------------------------------- Reporter: fengb | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 1.4 (models, ORM) | Resolution: Severity: Normal | Triage Stage: Accepted Keywords: | Needs documentation: 0 Has patch: 0 | Patch needs improvement: 0 Needs tests: 0 | UI/UX: 0 Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by fengb): Rejecting hashing on unsaved instances: https://github.com/fengb/django/tree/model-eq-hash-rejection There is one error with the change: forms is attempting to use hashing. I'm afraid of the other problems this backwards incompatible change will introduce. {{{ Traceback (most recent call last): File "/Users/bfeng/Documents/projects/django/tests/modeltests/model_formsets/tests.py", line 523, in test_inline_formsets_save_as_new self.assertTrue(formset.is_valid()) File "/Users/bfeng/Documents/projects/django/django/forms/formsets.py", line 269, in is_valid err = self.errors File "/Users/bfeng/Documents/projects/django/django/forms/formsets.py", line 247, in _get_errors self.full_clean() File "/Users/bfeng/Documents/projects/django/django/forms/formsets.py", line 293, in full_clean self.clean() File "/Users/bfeng/Documents/projects/django/django/forms/models.py", line 500, in clean self.validate_unique() File "/Users/bfeng/Documents/projects/django/django/forms/models.py", line 527, in validate_unique if row_data in seen_data: File "/Users/bfeng/Documents/projects/django/django/db/models/base.py", line 395, in __hash__ raise TypeError('unhashable without pk') TypeError: unhashable without pk }}} -- Ticket URL: <https://code.djangoproject.com/ticket/18864#comment:4> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.