Complete the code to import the base view class from Django.
from django.views import [1]
The base class for creating views in Django is View from django.views.
Complete the code to create a simple class-based view inheriting from the base view.
class MyView([1]): pass
To create a basic class-based view, inherit directly from View.
Fix the error in the method name to handle GET requests in a class-based view.
class MyView(View): def [1](self, request): return HttpResponse('Hello')
The method to handle GET requests in Django views is named get in lowercase.
Fill both blanks to correctly import HttpResponse and define a GET method returning a response.
from django.http import [1] class MyView(View): def get(self, request): return [2]('Hello World')
We import HttpResponse to send HTTP responses. The get method returns an HttpResponse instance.
Fill all three blanks to create a class-based view that handles POST requests and returns a simple response.
from django.views import [1] from django.http import [2] class SubmitView([3]): def post(self, request): return HttpResponse('Submitted')
The base class is View. We import HttpResponse to send responses. The class inherits from View.