Articles → DJANGO → List page in Django

List page in Django



from django.http import HttpResponse
from django.shortcuts import render
from .models import MyNewScreen

# Create your views here.
def home(request):
    return render(request, "template1.html", {})

def about(request):
    return render(request, "about.html", {})

def get_list(request):
    template_name = "get_list.html"
    queryset = MyNewScreen.objects.all()
    context = {"list": queryset}
    return render(request, template_name, context)

        <h1>My List</h1>
        {% for obj in list %}
            <li> {{}} </li>
        {% endfor %}

from django.contrib import admin
from django.urls import path
from TestModule.views import home
from TestModule.views import about
from TestModule.views import get_list

urlpatterns = [
    path("", home),
    path("about", about),
    path("get_list", get_list),

Picture showing the output of the list page in Django

Click to Enlarge

Posted By  -  Karan Gupta
Posted On  -  Wednesday, January 8, 2020


Your Email Id  
Query/FeedbackCharacters remaining 250