This is all true and good for simple model fields, but for more complex
ones where the python representation of the field value differs from that
in the database, this is at best misleading. An example of this is the
[https://docs.djangoproject.com/en/dev/howto/custom-model-
fields/#writing-a-field-subclass 'hand' example of field subclassing] in
the docs. For fields like this one, the first element of the model choices
field is the python representation of the field value, not the actual
value to be stored in the database.
I've implemented a [https://github.com/django/django/pull/2539/files pull
request] that implements a minor documentation change clarifying this, and
adds a test to the field subclassing to ensure this behavior is the
blessed behavior.
--
Ticket URL: <https://code.djangoproject.com/ticket/22537>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* needs_better_patch: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/22537#comment:1>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"7fd1b35ed794e7d0a2a18f6ac168adba25a7de23"]:
{{{
#!CommitTicketReference repository=""
revision="7fd1b35ed794e7d0a2a18f6ac168adba25a7de23"
Fixed #22537 -- Add tests and improved docs for field subclass with
choices.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22537#comment:2>
Comment (by Tim Graham <timograham@…>):
In [changeset:"bb5c7e4e8d783bf3a2880ab5cf1fa57fd35cd198"]:
{{{
#!CommitTicketReference repository=""
revision="bb5c7e4e8d783bf3a2880ab5cf1fa57fd35cd198"
[1.7.x] Fixed #22537 -- Add tests and improved docs for field subclass
with choices.
Backport of 7fd1b35ed7 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22537#comment:3>