#17080: Custom fields using attname, Model __init__ and Deserialization: hard-coded magic for relation fields --------------------------------------+------------------------------------ Reporter: anentropic | Owner: nobody Type: Bug | Status: reopened Component: Core (Serialization) | Version: 1.3 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 1 Easy pickings: 0 | UI/UX: 0 --------------------------------------+------------------------------------ Changes (by akaariai):
* component: Uncategorized => Core (Serialization) * stage: Unreviewed => Accepted Comment: In the patch there is this code: {{{ elif field.name != field.attname: data[field.attname] = field.to_python(field_value) # Handle all other fields else: data[field.name] = field.to_python(field_value) }}} Why not write it just as {{{ # Handle all other fields else: data[field.attname] = field.to_python(field_value) }}} As far as I see that is equivalent to what is done in the patch. This also models what `__init__` is doing. It expects all other fields by attname. To get the patch in ready for checkin stage, you will need to write your test case as a normal Django test case, that is a patch to tests directory. tests/modeltests/serializers/ seems to be a good directory for this. It would also be good to check if other deserializers suffer from this problem. -- Ticket URL: <https://code.djangoproject.com/ticket/17080#comment:5> 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 this group at http://groups.google.com/group/django-updates?hl=en.