Django нет обратного соответствия на heroku, но не локально
I am getting NoReverseMatch at /post/1/ Reverse for 'blog_home' not found. 'blog_home' is not a valid view function or pattern name. this error on my django website hosted on heroku, but the code works fine when I host the website locally. I think that it has something to do with heroku. My urls.py
urlpatterns = [
path('', PostListView.as_view(), name='blog-home'),
path('post/<int:pk>/', PostDetailView.as_view(), name='post-detail')
]
views.py: https://controlc.com/fd518ea0 (link because stack overflow said too much code)
Ошибка:
Environment:
Request Method: GET
Request URL: http://<appname>.herokuapp.com/post/1/
Django Version: 2.2.1
Python Version: 3.9.0
Template error:
In template /app/django_web_app/blog/templates/blog/base.html, error at line 0
Reverse for 'blog_home' not found. 'blog_home' is not a valid view function or pattern name.
1 : {% load staticfiles %}
2 : <!doctype html>
3 : <html lang="en">
4 : <head>
5 :
6 : <!-- Required meta tags -->
7 : <meta charset="utf-8">
8 : <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
9 :
10 :
Exception Type: NoReverseMatch at /post/1/
Exception Value: Reverse for 'blog_home' not found. 'blog_home' is not a valid view function or pattern name.
Версия Python: 3.9
Версия Django: 2.2.1
В urls.py, blog-home используется дефис. Неудачная строка меняет blog_home на символ подчеркивания.