tangowithcode / tango_with_django_19

A beginners guide to web programming with Python / Django 1.9
Apache License 2.0
207 stars 188 forks source link

/python_books/ doesn't return 404 as mentioned in Chap 6 > Parameterised URL Mapping section #47

Closed ProProgrammer closed 7 years ago

ProProgrammer commented 7 years ago

Chapter 6 > Parameterized URL mapping section mentions that

if the URL was rango/category/python_books/ or rango/category/££££-$$$$$/ then the sequence of characters between rango/category/ and the trailing / would not match the regular expression, and a 404 not found error would result

(This line is just before info section titled Regex Hell)

This is not true in the case of path rango/category/python_books/. Accessing this page returns HTML with test "The specified category does not exist" instead of 404. It looks like the underscores are matched by regex \w as per what is mentioned on Regular-Expressions.info

\w stands for "word character". It always matches the ASCII characters [A-Za-z0-9_]. Notice the inclusion of the underscore...

maxwelld90 commented 7 years ago

Hi @ProProgrammer, thanks for this. I'll have a look into this and see what I need to revise. Cheers!

maxwelld90 commented 7 years ago

Hi @ProProgrammer, thanks for this. I am updating the book, and took out the first example -- which does not yield a 404 as you say. Thank you for the spot!

Cheers, David