I'm receiving the below error when trying to link up my navbar in base.html in Django.
NoReverseMatch at / 'home' is not a registered namespace
I'm not sure why it's not working, any help would be much appreciated!
base.html:
<ul >
<li ><a href="{% url 'home:home' %}"><strong>Home</strong></a></li>
<li ><a href="{% url 'home' %}"><strong>My Health</strong></a></li>
<li ><a href="{% url 'login' %}"><strong>Login</strong></a></li>
<li ><a href="{% url 'signup' %}"><strong>Signup</strong></a></li>
</ul>
urls.py:
urlpatterns = [
path('', views.home, name='home'),
path('signup/', views.signup, name='signup'),
path('login/', views.login, name='login'),
path('favicon.ico', RedirectView.as_view(url=staticfiles_storage.url("favicon.ico"))),
path('success/', views.success_view, name='success'),
]
views.py:
def home(request):
return render(request, 'HealthHub/home.html')
CodePudding user response:
In your urls.py you should modify this line:
<li ><a href="{% url 'home' %}"><strong>Home</strong></a></li>
If you write home:home
django looks for an app_name called home in your urls.py file.