#514 closed defect (fixed)
[patch] Traceback in admin when adding an object containing a OneToOneField.
Reported by: | mmarshall | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | contrib.admin | Version: | 1.0 |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Working with objects that have a OneToOneField in the admin works fine when you click on "change" and then select one from the list. However, if you click on "Add", saving the object results in a traceback similar to this (with the rel_name of 'node'):
There's been an error: Traceback (most recent call last): <snip> File "/usr/lib/python2.4/site-packages/django/core/meta/fields.py", line 40, in manipulator_validator_unique old_obj = opts.get_model_module().get_object(**{'%s__exact' % f.name: field_data}) <snip> TypeError: got unexpected keyword argument 'node__exact'
A trivial patch solves the problem:
Index: django_src/django/core/meta/fields.py =================================================================== --- django_src/django/core/meta/fields.py (revision 642) +++ django_src/django/core/meta/fields.py (working copy) @@ -37,7 +37,7 @@ def manipulator_validator_unique(f, opts, self, field_data, all_data): "Validates that the value is unique for this field." try: - old_obj = opts.get_model_module().get_object(**{'%s__exact' % f.name: field_data}) + old_obj = opts.get_model_module().get_object(**{'%s__id__exact' % f.name: field_data}) except ObjectDoesNotExist: return if hasattr(self, 'original_object') and getattr(self.original_object, opts.pk.column) == getattr(old_obj, opts.pk.column):
MWM
Note:
See TracTickets
for help on using tickets.
Fixed in [643].
MWM