Saben estoy obteniendo este error “Reverse for ‘tatamaster_web.views.index’ not found. ‘tatamaster_web.views.index’ is not a valid view function or pattern name.” cuando trato de iniciar sesión usando ia clase ProductListView para llamar al index.html.
Cuando pongo en las urls.py views.index me carga, pero si pongo en la path(‘’, ProductListView.as_view(), name = ‘index’) no me deja iniciar sesión.
Este es el archivo url.py:
#Espero que esta vez si funcione
from django.contrib import admin
from django.urls import path
from . import views
from products.views import ProductListView
urlpatterns = [
path(‘’, ProductListView.as_view(), name = ‘index’),
#path(‘’, views.index, name = ‘index’),
path(‘usuarios/login’, views.login_view, name = ‘login’),
path(‘usuarios/logout’, views.logout_view, name = ‘logout’),
path(‘usuarios/registro’, views.register_view, name = ‘register’),
path(‘admin/’, admin.site.urls),
]
Y este es el views.py- products:
from django.shortcuts import render
from django.views.generic.list import ListView
from .models import Product
class ProductListView(ListView):
template_name = ‘index.html’
queryset = Product.objects.all().order_by(‘-id’)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['message'] = 'Listado de Productos'
context['products'] = context['product_list']
print(context)
return context
Te agradezco de antemano tu ayuda.