After #3515 is merged there are plenty of unnecessary re_path's left, but figuring out if simplification is possible is trickier.
Here are some known problems:
- regexpes that do not end with
$
- Year, month, and day-number could get their own patterns
- Ip-address could maybe get its own pattern
- Ditto hostnames
- There are several regexpes that could probably be covered by
<path: or <str: or <slug:
- No doubt many that take in
re_path(r'(?P<id>.+) could actually be replaced with path('<int:id>, and WAT about re_path(r'^x/(?P<id>.*) when re_path(r'^x/$ does not exist?
- Some regexpes end with
/?. APPEND_SLASH is implicitly True and django.middleware.common.CommonMiddleware is in use so this is probably redundant
When all the easy pickings have landed, https://regex101.com/ is useful to compare regexpes in order to simplify them. For instance, re_path(r'^(?P<id>\d+)$' and re_path(r'^(?P<id>[\d]+)$' are equivalent to path('<int:id>)' but `re_path(r'^(?P(\d+))$' is not and it is necessary to check what the view does in order to ascertain if the simplification is possible.
Originally posted by @hmpf in #3515
After #3515 is merged there are plenty of unnecessary
re_path's left, but figuring out if simplification is possible is trickier.Here are some known problems:
$<path:or<str:or<slug:re_path(r'(?P<id>.+)could actually be replaced withpath('<int:id>, and WAT aboutre_path(r'^x/(?P<id>.*)whenre_path(r'^x/$does not exist?/?. APPEND_SLASH is implicitly True anddjango.middleware.common.CommonMiddlewareis in use so this is probably redundantOriginally posted by @hmpf in #3515