Re:Django 2.0 alpha
by switch007 on Saturday September 23, 2017 @01:42PM
(#15320793)
How is <int:id> identical to (?P<year>[0-9]{4})? I'm talking about the {4}. Just an error in their blog post?
[ Parent
| on HN ]
Does 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 -b stable/2.0.x` and check out this convenient new feature.
Re:Django 2.0 alpha
by ubernostrum on Saturday September 23, 2017 @04:12PM
(#15321477)
It's still regex under the hood, the 'int' is just syntactic sugar for "[0-9]+":
https://github.com/django/django/blob/dda37675db0295baefef37...
Thanks!
Re:Django 2.0 alpha
by whalesalad on Saturday September 23, 2017 @04:09PM
(#15321454)
Seriously? 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.
You 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.