Discussion:
[Django] #25198: Django's model_to_dict should return ALL fields, including hidden
Django
2015-07-30 16:07:59 UTC
Permalink
#25198: Django's model_to_dict should return ALL fields, including hidden
--------------------------------------+---------------------------------
Reporter: 1st | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (Serialization) | Version: master
Severity: Normal | Keywords: model serialization
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+---------------------------------
Hello.

I found that Django return only editable fields in call of
`model_to_dict`. I wish to have an option `include_hidden=True` to get
list of ALL fields including not editable ones.

I will make this fix and tell you about fix.

--
Ticket URL: <https://code.djangoproject.com/ticket/25198>
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 django-updates+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/046.5b00c52bd4b2f031766aeedaa3919acf%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Django
2015-07-30 16:27:38 UTC
Permalink
#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
-------------------------------------+-------------------------------------
Changes (by 1st):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Created Pull Request https://github.com/django/django/pull/5070

--
Ticket URL: <https://code.djangoproject.com/ticket/25198#comment:1>
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 django-updates+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.345e38026e64d8d1d91782d161747ba4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Django
2015-07-30 16:31:16 UTC
Permalink
#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 timgraham):

This function isn't a documented public API, so if you are using it in
your own code, be aware that it could change without notice. I'm skeptical
of adding parameters that Django itself doesn't use to such a function.

--
Ticket URL: <https://code.djangoproject.com/ticket/25198#comment:2>
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 django-updates+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.ceefce924bfec9f86efdb55f868f9923%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Django
2015-07-30 16:33:16 UTC
Permalink
#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
-------------------------------------+-------------------------------------
Post by Django
This function isn't a documented public API, so if you are using it in
your own code, be aware that it could change without notice. I'm skeptical
of adding parameters that Django itself doesn't use to such a function.

I agree that this function isn' documented in Django docs, but me and a
lot of people use this function in their work. This non-breaking change
can simplify life for a lot of developers.

--
Ticket URL: <https://code.djangoproject.com/ticket/25198#comment:3>
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 django-updates+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.ae74bf0f671eb90991fc80eee58668db%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Django
2015-07-30 16:47:13 UTC
Permalink
#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 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?

--
Ticket URL: <https://code.djangoproject.com/ticket/25198#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 unsubscribe from this group and stop receiving emails from it, send an email to django-updates+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.6bc89b41e62ccc9e3a72a5c00357f3e5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Django
2015-07-30 16:56:38 UTC
Permalink
#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
-------------------------------------+-------------------------------------
Post by Django
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 django-updates+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
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.
Django
2015-07-30 17:32:33 UTC
Permalink
#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 timgraham):

Would there be some value in trying to improve the speed of Django's
serialization instead of needing to roll your own?

--
Ticket URL: <https://code.djangoproject.com/ticket/25198#comment:6>
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 django-updates+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.1512d8da9ea8964e0e231f61d3a443ed%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Django
2015-07-30 18:04:46 UTC
Permalink
#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
-------------------------------------+-------------------------------------
Post by Django
Would there be some value in trying to improve the speed of Django's
serialization instead of needing to roll your own?

In this task I don't propose to improve serializer. My change is simple
and used widely. You can google "how to convert django model to dict" and
se on stackoverflow how people do this.

--
Ticket URL: <https://code.djangoproject.com/ticket/25198#comment:7>
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 django-updates+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.dfe9f4d81a3768e426260b08b49b5331%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Django
2015-07-30 18:28:36 UTC
Permalink
#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 timgraham):

Are you willing to write to the mailing list to describe your problem and
elaborate on why `model_to_dict()` is the best solution such that it
should be a public API? This discussion needs to involve more than just me
and you. Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/25198#comment:8>
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 django-updates+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.ba0d41fadef05b3f189df558a8c177a5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Django
2015-07-30 18:29:57 UTC
Permalink
#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
-------------------------------------+-------------------------------------
Post by Django
Are you willing to write to the mailing list to describe your problem
and elaborate on why `model_to_dict()` is the best solution such that it
should be a public API? This discussion needs to involve more than just me
and you. Thanks!

OK, will do. Please tell me the adress of mailing list. Do you mean Google
Groups Django group?

--
Ticket URL: <https://code.djangoproject.com/ticket/25198#comment:9>
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 django-updates+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.0c52842c3c7fe7b77638c4b285f81f0b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Django
2015-07-31 13:14:29 UTC
Permalink
#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 timgraham):

The DevelopersMailingList.

--
Ticket URL: <https://code.djangoproject.com/ticket/25198#comment:10>
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 django-updates+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.a5ab95b43291bb81e4c9274ff52488f2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Loading...