I created my first Django Trac ticket. Milestone?
-
Marijke Luttekesreplied to Marijke Luttekes last edited by
-
Carlton Gibson ๐ช๐บreplied to Marijke Luttekes last edited by
@mahryekuh Grrr. OK. I might have to play with that. Let me see...
-
Marijke Luttekesreplied to Carlton Gibson ๐ช๐บ last edited by
@carlton For completeness, this is the code I used, although it's very much based on what you provided:
```python
from django.db.models import fields
from django.utils.translation import gettext_lazy as _# Monkey patch:
# See also: https://code.djangoproject.com/ticket/35870
fields.BLANK_CHOICE_DASH = [('', _('(select an option)'))]
``` -
Carlton Gibson ๐ช๐บreplied to Marijke Luttekes last edited by
@mahryekuh Does this...
def get_choices(
self,
include_blank=True,
blank_choice=BLANK_CHOICE_DASH,
limit_choices_to=None,
ordering=(),
... mean it's set at class definition time? I think it might, which means it won't pick up the change. (I always have to think too hard about these cases, but that's likely the issue.) Bugger.
-
Carlton Gibson ๐ช๐บreplied to Carlton Gibson ๐ช๐บ last edited by
@mahryekuh You'll see the comment. Sorry for the mis-steer
-
Marijke Luttekesreplied to Carlton Gibson ๐ช๐บ last edited by
@carlton That's OK!
I am kind of surprised that the blank_choice kwarg even exists since, so far, I haven't seen it being used in core.
I don't know if a third-party package uses this kwarg, but it might be a blessing if we refactor this one.
(And with we, I mean that Thibaud has given himself ownership now)
-
Carlton Gibson ๐ช๐บreplied to Marijke Luttekes last edited by
@mahryekuh Go @thibaudcolas Go! ๐ฆธ
-
@mahryekuh Congratulations!
-
Alex Tomkinsreplied to Marijke Luttekes last edited by
@mahryekuh Ooh, yes please!
It's one we monkey patched ages ago, mostly as a design decision rather than for accessibility - but it would be a good one to make a bit easier to customise.
-
Marijke Luttekesreplied to Alex Tomkins last edited by
@alextomkins Do you remember how you monkey patched this thing? Carlton and I discovered that patching via Django settings and AppConfig.ready() doesnโt work.
-
Alex Tomkinsreplied to Marijke Luttekes last edited by [email protected]
@mahryekuh Adding it to settings.py - https://github.com/developersociety/django-template/blob/57b63bb25450ed6b78951fa5ba174bc8f46e39d0/%7B%7Bcookiecutter.project_slug%7D%7D/project/settings/base.py#L189
Although, just playing around with the code - it might not be a case of *where* it gets imported. Just tried changing it to `BLANK_CHOICE_DASH` - it doesn't override it, but `BLANK_CHOICE_DASH[0]` does.