django 使用包含土耳其语字符的 link

django using a link containing turkish characters

我正在创建 Django 项目。 Django 允许在 auth.User 模型中使用土耳其语字符 (ş,ü,ö,İ,ğ,ı,ç)。但我想在链接中使用用户名。例如,app.com/şüöİğıç. 当我在电脑上处理一些链接(包含土耳其语字符)时没有问题。我发布项目时有什么问题吗?我不能使用 slugify,因为一个用户可以是“şam”,一个用户可以是 'sam'。所以这可能是冲突的。 我想创建仅使用英文字母的用户名验证器。我能怎么做? 简而言之,在链接上使用土耳其字母时是否有任何问题(app.com/şüöİğıç),如果有问题我该如何解决这个问题。

forms.py:

class registerForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
class Meta:
    model = User
    fields = ["email","first_name","last_name","password","username"]


    #model = ACCOUNTS
    #fields=['email','name','surname','username','password','birthday','gender','language']

看看https://www.rfc-editor.org/rfc/rfc3987 :

This document defines a new protocol element, the Internationalized Resource Identifier (IRI), as a complement to the Uniform Resource Identifier (URI). An IRI is a sequence of characters from the Universal Character Set (Unicode/ISO 10646). A mapping from IRIs to URIs is defined, which means that IRIs can be used instead of URIs, where appropriate, to identify resources.

这解释了当字符超出 ASCII 范围时如何生成正确的 URL。 例如:http://www.w3.org/People/D%C3%BCrst/