`if fields and f.name not in fields:`
which should be
`if fields is not None and f.name not in fields:`
PR: https://github.com/django/django/pull/11150/files
--
Ticket URL: <https://code.djangoproject.com/ticket/30302>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* version: 2.1 => master
* type: Bug => Cleanup/optimization
Comment:
`model_to_dict()` is a part of private API. Do you have any real use case
for passing empty list to this method?
--
Ticket URL: <https://code.djangoproject.com/ticket/30302#comment:1>
* stage: Unreviewed => Accepted
* needs_tests: 0 => 1
Comment:
[https://github.com/django/django/pull/11150 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/30302#comment:2>
Comment (by Belegnar):
This method is comfortable to fetch instance fields values without
touching ForeignKey fields. List of fields to be fetched is an attr of the
class, which can be overridden in subclasses and is empty list by default
Also, patch been proposed is in chime with docstring and common logic
--
Ticket URL: <https://code.djangoproject.com/ticket/30302#comment:3>
* needs_tests: 1 => 0
Comment:
[https://github.com/django/django/pull/11163 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/30302#comment:4>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/30302#comment:5>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"1ffddfc233e2d5139cc6ec31a4ec6ef70b10f87f" 1ffddfc]:
{{{
#!CommitTicketReference repository=""
revision="1ffddfc233e2d5139cc6ec31a4ec6ef70b10f87f"
Fixed #30302 -- Fixed forms.model_to_dict() result if empty list of fields
is passed.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30302#comment:7>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"714cf468e10ccbfca6a97095939563a52b99e2eb" 714cf468]:
{{{
#!CommitTicketReference repository=""
revision="714cf468e10ccbfca6a97095939563a52b99e2eb"
Refs #30302 -- Added more tests for forms.model_to_dict().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30302#comment:6>