Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

 What is Class View in Django?

The class view is used to create view methods using class and object pattern, it provides better usability and oops features implementation in the Django Project.

Django provides a separate module to implement Class View


Step1st:-

go into views.py and create a class using the following module:


from django.views import View

class GreetingView(View):

    greeting = "Good Day"


    def get(self, request):

        return HttpResponse(self.greeting)


Step2nd:-

Implement Urls to define a class view:-


from frontdesk.views import GreetingView


urlpatterns = [

 path('grt/', GreetingView.as_view()),

 ]




Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post