程序设计应用 2023-03-25

发布时间 2023-03-25 10:41:13作者: ChuckLu

how many types supported in url path

There are several types that can be used in URL patterns in Django. Here are some of the most commonly used types:

str: Matches any non-empty string, excluding the path separator (/).
int: Matches any positive integer.
slug: Matches any slug string consisting of ASCII letters or numbers, plus hyphens and underscores.
uuid: Matches a UUID in hexadecimal format, with or without hyphens.
path: Matches any non-empty string, including the path separator (/).
You can also define your own custom types by subclassing django.urls.converters.StringConverter and implementing the to_python and to_url methods.