Movie ratings

Report a typo

The client for your application is a user who wants to know what rating a particular film has. You only have several ratings, all of which are stored in the CINEMA_RATINGS dictionary.

CINEMA_RATINGS = {
    "The Dark Knight": 8.2,
    "The Shawshank Redemption": 8.3,
    "Pulp Fiction": 8.1,
}

You should implement a handler for the GET requests.

If a film has a rating, you should return a HttpResponse with only a rating in it.

If there is no such film in your rating database, raise Http404 Exception.

Do not modify other methods and variables of CinemaRatingView class.

Write a program in Python 3
from django.http import HttpResponse, Http404
from django.views import View


class CinemaRatingView(View):
description = "Cinema ratings list"

def __str__(self):
return self.description

def get(self, request, film, *args, **kwargs):
...
___

Create a free account to access the full topic