Articles → DJANGO → Listview In Django
from django.http import HttpResponse from django.shortcuts import render from .models import MyNewScreen from django.views.generic import ListView class MyListView(ListView): template_name = "get_list.html" queryset = MyNewScreen.objects.all()
from django.contrib import admin from django.urls import path from TestModule.views import ( MyListView, ) urlpatterns = [ path("admin/", admin.site.urls), path("mylist", MyListView.as_view()), ]
<html> <body> <h1>My List</h1> <ul> {% for obj in object_list %} <li> {{ obj.name}} </li> {% endfor %} </ul> </body> </html>
Query/Feedback