I have this error:
NoReverseMatch at / Reverse for 'peliculas' not found. 'peliculas' is not a valid view function or pattern name. Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 2.1.2 Exception Type: NoReverseMatch Exception Value:
Reverse for 'peliculas' not found. 'peliculas' is not a valid view function or pattern name. Exception Location: C:\Users\Angel\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 622 Python Executable: C:\Users\Angel\AppData\Local\Programs\Python\Python37\python.exe Python Version: 3.7.1 Python Path:
['C:\Users\Angel\Desktop\Trabajos\Videoclub\videoclub_django', 'C:\Users\Angel\AppData\Local\Programs\Python\Python37\python37.zip', 'C:\Users\Angel\AppData\Local\Programs\Python\Python37\DLLs', 'C:\Users\Angel\AppData\Local\Programs\Python\Python37\lib', 'C:\Users\Angel\AppData\Local\Programs\Python\Python37', 'C:\Users\Angel\AppData\Local\Programs\Python\Python37\lib\site-packages']
I just dont get what's happening
You can see full code here:
https://github.com/AngelQuesada/videoclub_django
This is the part where it fails (base_generic.html)
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="{% url 'index' %}">Inicio
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'peliculas' %}">Peliculas</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Directores</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Actores</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Géneros</a>
</li>
<li class="nav-item">
<a class="nav-link" href="http://127.0.0.1:8000/admin/">Administración</a>
</li>
</ul>
</div>
My urls.py file:
from django.contrib import admin
from django.urls import path, include, re_path
from django.conf.urls import url
from . import views
app_name = "videoclub"
urlpatterns = [
path('', views.index, name="index"),
url(r'^peliculas/$', views.PeliculaListView.as_view(), name='peliculas'),
# url(r'^pelicula/(?P<pk>\d+)$', views.DetailPeliculaView.as_view(),
name='detalle-pelicula'),
]
Thanks in advance guys!
You've namespaced your URLs in the videoclubs
app. So rather than just {% url 'peliculas' %}
you should use {% url 'videoclub:peliculas' %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With