Question: Python decorators can be used in Django in order to avoid duplication of code in view functions. For instance, consider the following definition of a

Python decorators can be used in Django in order to avoid duplication of code in view functions. For instance, consider the following definition of a decorator that is then applied to a view function. This code has three bugs: 01: def fetch_author(view_func) : 02: def wrapper(request, *args, kwargs): 03: try: 04: author = Author.objects.get (id=request.GET ["author_id"]) 05: view_func (request, author, *args, **kwargs) 06: except Author.DoesNotExist: 07: return bad_request(request, Author.DoesNotExist) 08: return view_func 09: 10: @fetch_author 11: def books_new(request) : 12: books = Book. objects.filter(authors_in= [author], year_gte="2015") 13: context ={ 14: "title" : "New books", 15: "books" : books, 3 return render (request, "books-recent.html", context) Identify the three lines which contain the three bugs: Line 02 Line 05 Line 08 Line 11 Line 12 Line 17
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
