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