Code review comment for lp:~milo/linaro-ci-dashboard/xml-to-dict

Revision history for this message
Milo Casagrande (milo) wrote :

On Fri, Sep 7, 2012 at 12:28 PM, Stevan Radaković
<email address hidden> wrote:
> Good idea... We could also check if we can somehow make use of the
> 'exclude' option in the Meta subclass for filtering out the fields; or
> create our own option if it's not good match for us.

Unfortunately, we can't. The exclude option in the Meta class is only
available for the class that inhertis from Form, not for the models.
I pushed the last changes into the branch associated with this MP.

There is a "problem" also with using "model_to_dict": not all the
fields will be serialized to a dictionary. I wrote a note in the code.
The problem is with fields set as "editable=False". That parameter is
used with Form display, but since the "model_to_dict" is a function
taken from the "forms" part of Django, that parameter applies here as
well, so we do not get back everything, even if we include it in the
list of fields we want back.

I tried also with the serializers, but we would need to craft the
correct query, since the filter and exlude functions on serializers
need to have actual values to operate (we would end up doing, etc...).
The other options I see are or using getattr, or through
obj.__dict__['field_string']. With both approaches we would still need
to pass a list of fields we want or we want to exclude.

Milo Casagrande
Infrastructure Engineer <> │ Open source software for ARM SoCs

« Back to merge proposal