You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Piotr,
Sounds strange. However, this is over the old version -- I fixed several things that were outstanding and it looks like this is one of them. The code above is a hangover from Django 1.9/1.10/1.11, where it uses regex to map patterns. So you are technically correct in trying re_path() to fix this issue.
However, I've updated the book since you reported this to use the following:
Instructions have been updated to reflect this change in URL/name.
Not sure I can replicate the behaviour regarding multiple likes coming down on it when the page is refreshed? That is very strange. Again, code has been revised -- if you want to check our model solution on the new code GitHub, would you agree with what I have put in?
On Django 2.2 this doesn't work as expected:
“Don’t forget to add in the URL mapping, into rango/urls.py. Update the urlpatterns by adding in:
path('like$', views.like_category, name='like_category'),”
I read the docs and tried this:
re_path(r'^like/$', views.like_category, name="like_category"),
and it kind of works, but after the first like, every time I refresh once liked category, refresh automatically adds +1 to the number of likes.
In the console it's visible that opening/refreshing the category is requesting 'like_category' view at the same time:
[12/Jul/2019 19:39:02] "GET /rango/like/?category_id=5 HTTP/1.1" 200 2
[12/Jul/2019 19:39:02] "GET /rango/category/python/ HTTP/1.1" 200 6311
The text was updated successfully, but these errors were encountered: