Opened 3 years ago

Closed 3 years ago

#32598 closed Bug (invalid)

Issue in models.SlugField

Reported by: MojixCoder Owned by: nobody
Component: Core (URLs) Version: 3.1
Severity: Normal Keywords: slug
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

After setting allow_unicode=True for a SlugField in Our models we cant still use persian slugs because in <slug:slug> it doesn't accept unicode slugs ( take a look at slug regex ).

path('<slug:slug>/', CategoryArticlesView.as_view(), name="category"),
Reverse for 'category' with arguments '('برنامه-نویسی',)' not found. 1 pattern(s) tried: articles/(

remember than allow_unicode=True is working fine in SlugField but url <slug:slug> doesn't accept it

Change History (1)

comment:1 by Mariusz Felisiak, 3 years ago

Resolution: invalid
Status: newclosed

SlugField.allow_unicode doesn't impact path converters. It is also documented that:

slug - Matches any slug string consisting of ASCII letters or numbers, plus the hyphen and underscore characters. For example, building-your-1st-django-site.

You can create a custom path converter or use re_path().

Note: See TracTickets for help on using tickets.
Back to Top