[Django] #25480: CharField + choices + default = fields.E008

11 views
Skip to first unread message

Django

unread,
Sep 28, 2015, 11:13:16 AM9/28/15
to django-...@googlegroups.com
#25480: CharField + choices + default = fields.E008
----------------------------------------------+--------------------
Reporter: Kondou-ger | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer (models, ORM) | Version: 1.9a1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
Have this as your models.py:

{{{
from django.db import models
from django.utils.translation import ugettext_lazy

breakage_status = (
(ugettext_lazy("In queue"), 'queue'),
(ugettext_lazy("Processing"), 'proces'),
(ugettext_lazy("Done"), 'done'),
)

class Breakage(models.Model):
status = models.CharField(max_length=6, default="queue",
choices=breakage_status)
}}}

Results in:
{{{
(project)kondou:project/ (master✗) $ ./manage.py check
SystemCheckError: System check identified some issues:

ERRORS:
project.Breakage.status: (fields.E008) Invalid 'default' value: Value
'queue' is not a valid choice.

System check identified 1 issue (0 silenced).
}}}
with `default="queue"`
{{{
(project)kondou:project/ (master✗) $ ./manage.py check
SystemCheckError: System check identified some issues:

ERRORS:
project.Breakage.status: (fields.E008) Invalid 'default' value: Value
"(<django.utils.functional.lazy.<locals>.__proxy__ object at
0x7ff17180d358>, 'queue')" is not a valid choice.

System check identified 1 issue (0 silenced).
}}}
with `default=breakage_status[0]`

{{{
(project)kondou:project/ (master✗) $ ./manage.py check
SystemCheckError: System check identified some issues:

ERRORS:
project.Breakage.status: (fields.E008) Invalid 'default' value: Value
'queue' is not a valid choice.

System check identified 1 issue (0 silenced).
}}}
with `default=breakage_status[0][1]`

{{{
(project)kondou:project/ (master✗) $ ./manage.py check
SystemCheckError: System check identified some issues:

ERRORS:
project.Breakage.status: (fields.E008) Invalid 'default' value: Ensure
this value has at most 6 characters (it has 8).

System check identified 1 issue (0 silenced).
}}}
with `default=breakage_status[0][0]`.

--
Ticket URL: <https://code.djangoproject.com/ticket/25480>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 28, 2015, 11:18:23 AM9/28/15
to django-...@googlegroups.com
#25480: CharField + choices + default = fields.E008
-------------------------------------+-------------------------------------

Reporter: Kondou-ger | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 1.9a1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


Comment:

Hi,

Did you mean to do this?

{{{
breakage_status = (
('queue', ugettext_lazy("In queue")),
('process', ugettext_lazy("Processing")),
('done', ugettext_lazy("Done")),
)
}}}

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

Django

unread,
Sep 28, 2015, 11:21:24 AM9/28/15
to django-...@googlegroups.com
#25480: CharField + choices + default = fields.E008
-------------------------------------+-------------------------------------
Reporter: Kondou-ger | Owner: nobody
Type: Uncategorized | Status: closed

Component: Database layer | Version: 1.9a1
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kondou-ger):

* status: new => closed
* resolution: => invalid


Comment:

Replying to [comment:1 collinanderson]:


> Hi,
>
> Did you mean to do this?
>
> {{{
> breakage_status = (
> ('queue', ugettext_lazy("In queue")),
> ('process', ugettext_lazy("Processing")),
> ('done', ugettext_lazy("Done")),
> )
> }}}
>

No I meant it in reverse … It's wrong I just realized. Wondering how this
worked out for me in 1.8 … Closing …

--
Ticket URL: <https://code.djangoproject.com/ticket/25480#comment:2>

Django

unread,
Sep 28, 2015, 11:39:34 AM9/28/15
to django-...@googlegroups.com
#25480: CharField + choices + default = fields.E008
-------------------------------------+-------------------------------------
Reporter: Kondou-ger | Owner: nobody

Type: Uncategorized | Status: closed
Component: Database layer | Version: 1.9a1
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by charettes):

I'm afraid it wasn't working correctly in 1.8 and the newly added
`'fields.E008'` check spotted it.

You might want to investigate if your database doesn't contain `'Done'`
entry for this field or `'In que'` and `'Process'` if you're using MySQL
which does silent truncation of value when it cannot fit a `VARCHAR`
instead of raising an integrity error.

--
Ticket URL: <https://code.djangoproject.com/ticket/25480#comment:3>

Reply all
Reply to author
Forward
0 new messages