[Fixed]-Following button on site not working

1👍

Try adding a ‘$’ to the end of your urls. Django tries to match the urls from first to last, and since your first regular expression matches the url you’re trying to visit, it doesn’t bother looking further and goes to it. The ‘$’ will end the regular expression.

urls.py

urlpatterns = [
    url(r'^profile/(?P<username>[\w.@+-]+)$', views.UserDetailView.as_view(), name="viewprofile"),
    url(r'^profile/(?P<username>[\w.@+-]+)/follow$', views.UserFollowView.as_view(), name="follow"),]
👤JLink

0👍

If the page “just refreshes”, it sounds like the button HTML itself is incorrect. I had this problem yesterday and after an hour of digging into my JS and Python, I realized that a button automatically submits a form on the page unless it is declared with the type “button” like this:

<button type="button" ....>

Leave a comment