tangowithcode / tango_with_django_2

Django 2 and Python 3: Tango With Django 2 Book Repository
Apache License 2.0
68 stars 23 forks source link

Chapter 15 reverse() URL lookup is missing in the book #9

Closed ntairov closed 4 years ago

ntairov commented 4 years ago

In the last version of the book, on page 256, in the code instead of return redirect(reverse('rango:index')) it is
return redirect('rango:index') in the repo it is missing too https://github.com/maxwelld90/tango_with_django_2_code/blob/36cd3e6d2f8efd6e68634a04ea15b24de606857f/tango_with_django_project/rango/views.py#L220

Also, I don't know, whether it is correct or not, but on page 251,in the piece of code there are double time written line if request.method == 'POST', I guess it has to be written once ? https://github.com/maxwelld90/tango_with_django_2_code/blob/e5401416fe47a08ed57bc138bda9bae9bfe370cc/tango_with_django_project/rango/views.py#L47

maxwelld90 commented 4 years ago

Hi @ntairov, thank you for reporting this! I've got a few edits to make and will check your issue out over the next few days.

maxwelld90 commented 4 years ago

Hi @ntairov, Thanks for getting in touch and reaching out with these issues.

Regarding the lack of reverse() within the calls to redirect() in and around page 256 of the book, you are correct. However, if you look at the Django documentation for the redirect() method, one of the possible options you can give the method is a URL name. Therefore, the code should work fine. However, I do appreciate that it can be a bit confusing so the first time that happens, I'm going to add a little disclaimer explaining what is going on here.

Regarding the second issue, that's a fair point. Code works but the second condition isn't required. It's actually a "gotcha" for students -- we put in a couple of things here and there to see whether students who use this book at universities, etc. actually just copy/paste the code from the repository. But thanks for bringing it to our attention 👍