Question : list views django
Answered by : manish-bhusal
{"tags":[{"tag":"textarea","content":"# posts/views.py\nfrom django.views.generic import ListView from .models import Post\n\nclass HomePageView(ListView): \n \t\n model = Post\n\n template_name = 'home.html'\n\n context_object_name = 'all_posts_list' # change object_list name to\n \t\t\t\t\t\t\t\t\t\t\t\t\t\t# anything","code_language":"python"}]}
Source : | Last Update : Mon, 29 May 23
Question : django class based views
Answered by : crazy-cobra-t8dxfk4qlack
from django.http import HttpResponse
from django.views import View
class MyView(View): def get(self, request): # <view logic> return HttpResponse('result')
Source : https://docs.djangoproject.com/en/4.0/topics/class-based-views/intro/ | Last Update : Thu, 12 May 22
Question : views django
Answered by : horrible-hippopotamus-8bhbr6nv9o2v
from django.http import HttpResponse
import datetime
def current_datetime(request): now = datetime.datetime.now() html = "<html><body>It is now %s.</body></html>" % now return HttpResponse(html)
Source : | Last Update : Tue, 16 Mar 21
Question : django class based views ListView
Answered by : perfect-pigeon-lz4ue7dtjqq3
# views.py
from django.views.generic import ListView
from books.models import Publisher
class PublisherListView(ListView): model = Publisher
Source : https://docs.djangoproject.com/en/3.2/topics/class-based-views/generic-display/ | Last Update : Sat, 10 Jul 21