[Django] #22537: Misleading documentation on choices for a model field

8 views
Skip to first unread message

Django

unread,
Apr 29, 2014, 1:07:14 AM4/29/14
to django-...@googlegroups.com
#22537: Misleading documentation on choices for a model field
-------------------------------+--------------------
Reporter: carbonXT | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------
The [https://docs.djangoproject.com/en/dev/ref/models/fields/#choices docs
on the choices attribute for a model field] currently read "The first
element in each tuple is the actual value to be stored..."

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.

Django

unread,
Apr 29, 2014, 7:02:20 AM4/29/14
to django-...@googlegroups.com
#22537: Misleading documentation on choices for a model field
-------------------------------+------------------------------------

Reporter: carbonXT | Owner: nobody
Type: Bug | Status: new
Component: Documentation | Version: 1.6
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by timo):

* needs_docs: => 0
* needs_better_patch: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/22537#comment:1>

Django

unread,
Apr 30, 2014, 7:57:31 AM4/30/14
to django-...@googlegroups.com
#22537: Misleading documentation on choices for a model field
-------------------------------+------------------------------------
Reporter: carbonXT | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 1.6
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* 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>

Django

unread,
Apr 30, 2014, 7:58:01 AM4/30/14
to django-...@googlegroups.com
#22537: Misleading documentation on choices for a model field
-------------------------------+------------------------------------
Reporter: carbonXT | Owner: nobody
Type: Bug | Status: closed
Component: Documentation | Version: 1.6

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages