I have a model called ResourceFile defined similarly as so:
class ResourceFile(models.Model):
BROCHURE, DATA_SHEET, APPLICATION_NOTE, TECHNICAL_NOTE = range(0, 4)
RESOURCE_TYPES = (
(BROCHURE, _("Brochure")),
(DATA_SHEET, _("Data Sheet")),
(APPLICATION_NOTE, _("Application Note")),
(TECHNICAL_NOTE, _("Technical Note")),
)
file = models.FileField(_("File"), blank=True, null=True)
title = models.CharField(_("Title"), max_length=255)
resource_type = models.PositiveSmallIntegerField(
_("Resource Type"),
choices=RESOURCE_TYPES
)
The URL to view these resource_types
is defined as so:
path(
_("resources/<slug:resource_type>"),
views.ResourceFileList.as_view(),
name="resource-detail-list"
)
I am using two languages. resource_type
is translated in Simplified Chinese using the .po and .mo files. I’m getting this error in the sitemap.xml:
NoReverseMatch at /sitemap.xml
Reverse for 'resource-detail-list' with keyword arguments
'{'resource_type': '手册s'}' not found. 1 pattern(s) tried:
['zh\\-hans/资源/(?P<resource_type>[-a-zA-Z0-9_]+)[\\Z](file://Z)']
Based on the error message, it becomes evident that the slug
parameter used inside path
does not take Unicode characters. Is there a reason for this limitation? Could I convince the Django Developers to change it and be more inclusive with the slug
parameter? How does anyone else manage this issue?