4 ms·
There's new `path()` as alternative to `url()` that allows one to use easier to remember syntax for url params like `<int:id>` instead of past `(?P<year>[0-9]{4
by Ralfp 9y ago
There's new `path()` as alternative to `url()` that allows one to use easier to remember syntax for url params like `<int:id>` instead of past `(?P<year>[0-9]{4})`. But if you need it, there's still `url()` for you to use power of regex in your urls.
And your shop still runs on Py2k, you'll need to move to Py3k to use Django 2.0. This also means that websockets support will not land on Django version that works for Py2k.
- switch007 9y agoHow is <int:id> identical to (?P<year>[0-9]{4})? I'm talking about the {4}. Just an error in their blog post?
- westurner 9y agoDoes it support negative long integers? EDIT: I am without actual internet or mobile tethering and an unable to `git clone https://github.com/django/django https://github.com/django/django -b stable/2.0.x` and check out this convenient new feature.
- whalesalad 9y agoSeriously? I mean you can achieve that with your own regex the old way. Surprised you’re asking the commenters here to investigate such a specific and odd use case of a convenience method.
- ubernostrum 9y agoIt's still regex under the hood, the 'int' is just syntactic sugar for "[0-9]+": https://github.com/django/django/blob/dda37675db0295baefef3750e12430cf9df4d835/django/urls/converters.py#L6 https://github.com/django/django/blob/dda37675db0295baefef37...
- westurner 9y agoThanks!
- lozenge 9y agoYou normally would want a three digit year to 404, and the same is true for a silly year like `3456` - you would 404 in the view. So, it isn't identical, but close enough for most purposes, as your view probably already has code to return 404.