#25198: Django's model_to_dict should return ALL fields, including hidden
-------------------------------------+-------------------------------------
Reporter: 1st | Owner: nobody
Type: Uncategorized | Status: new
Component: Core | Version: master
(Serialization) |
Severity: Normal | Resolution:
Keywords: model serialization | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by 1st):
Replying to [comment:4 timgraham]:
> If it's widely used, then we should consider making it a public API and
documenting it. Perhaps you could give your rationale on the
DevelopersMailingList? If the function is meant as a general
"serialization" utility as you categorized the ticket, `forms.models`
seems like it might not be the best place to expose such functionality.
Does the Python serializer in `core.serializers` not work for your use
case?
Django `serializer` work very slow compared to my own implementation of
serialization. I compared it with what I created manually and I can save
about 50% of time on make response with serialized queryset. It's why I
get serialized list of objects and convert them to list of values that I
need.
Now I use this way to get list of model fields:
{{{
def get_model_fields(obj):
return sorted(options.concrete_fields, options.virtual_fields,
options.many_to_many)
}}}
But it will be better to get list of ALL model fields as simple call
`model_to_dict(obj, include_hidden=True)`
--
Ticket URL: <https://code.djangoproject.com/ticket/25198#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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/061.ddd7b70b9a1415c4a1e1085b8f285d99%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.