Could this be implemented as an argument for the default template filter?
Or a separate default template filter?
Which version would be preferred?
`{{ value|slugify:allow_unicode=True }}`
or
`{{ value|slugify_unicode }}`
?
--
Ticket URL: <https://code.djangoproject.com/ticket/34567>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => tuxo
* status: new => assigned
* type: Uncategorized => New feature
* stage: Unreviewed => Accepted
Comment:
Reproduced.
{{{
>>> from django.utils.text import slugify
>>> slugify("你好 ni hao")
'ni-hao'
>>> slugify("你好 ni hao", allow_unicode=True)
'你好-ni-hao'
}}}
but given following context
{{{
{"my_text": "你好 ni hao"}
}}}
in the template
{{{
<p>{{ my_text | slugify }}</p>
}}}
it produces
{{{
ni-hao
}}}
i agree that a way to allow unicode from the template filter should exist
--
Ticket URL: <https://code.djangoproject.com/ticket/34567#comment:1>
* status: assigned => closed
* resolution: => duplicate
* component: Uncategorized => Template system
* stage: Accepted => Unreviewed
Comment:
Duplicate of #8391. Also, the current thread is to keep Django a core
framework, not providing every utility which might be useful. You can
write that filter in your own library. You can start a discussion about
#8391 on DevelopersMailingList if you don't agree.
--
Ticket URL: <https://code.djangoproject.com/ticket/34567#comment:2>
Comment (by benjaoming):
> Duplicate of #8391.
Thanks Mariusz, I did look at that issue, and I should have noted it in
the description - but ''I think'' #8391 is from before
django.utils.text.slugify existed and provided allow_unicode. The previous
issue was mostly about the complex area of mapping one character to
another - allow_unicode=True doesn't want to map anything AFAIK.
> Also, the current thread is to keep Django a core framework, not
providing every utility which might be useful.
That's fair. The functionality is already implemented in django.utils.text
- so this is only a proposal to expose the keyword `allow_unicode`. But
yeah, exposing it will of course lead to more usage.
I was particularly intrigued by the fact that I had introduced bugs in my
codebase because I used `|slugify` without considering its affect on
translated versions.
> You can start a discussion about #8391 on DevelopersMailingList if you
don't agree.
That's a nice page <3 I have been "WONTFIX'ed" :) I don't feel like having
a discussion on this topic. I tried to write a topic for the forum, but it
became disproportionate -- adding the keyword to the template filter is
both very easy to implement in Django defaultfilters, it's also very easy
to port my own boilerplate around between projects. If it cannot be a
quick yes/no, then I think leaving it aside is better.
--
Ticket URL: <https://code.djangoproject.com/ticket/34567#comment:3>
Comment (by Mariusz Felisiak):
Replying to [comment:3 benjaoming]:
> That's a nice page <3 I have been "WONTFIX'ed" :) I don't feel like
having a discussion on this topic. I tried to write a topic for the forum,
but it became disproportionate -- adding the keyword to the template
filter is both very easy to implement in Django defaultfilters, it's also
very easy to port my own boilerplate around between projects. If it cannot
be a quick yes/no, then I think leaving it aside is better.
Not you, it's been "wontfixed" 9 years ago ;) I'm just trying to keep a
discussion in a single place 🧹. TBH, I'm fine with exposing
`allow_unicode` in the `slugify` template filter but we should do this by
reopening #8391. You can start a short thread on the Django Forum or the
mailing list, a few "+1" should be enough to reopen.
--
Ticket URL: <https://code.djangoproject.com/ticket/34567#comment:4>