About Path Converters
Since Django 2.0, url()
for URL configurations is replaced with path()
:
path(
"blog/<slug:post_slug>/",
views.post_details,
name="post_details",
),
These are the default types of URL components called path converters:
Path Converter | Description |
---|---|
str | any string excluding "/" |
int | zero or a positive number |
slug | ASCII letters or numbers, hyphen, and underscore |
uuid | formatted UUID |
path | any string including "/" |
Custom path converters can be added too. More complex regular expressions can be implemented with re_path()
.
Tips and Tricks Programming Django 4.2 Django 3.2 Django 2.2
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django GDPR Cookie Consent app
For Django websites that use cookies.