Complete the code to import the permission decorator from Django.
from django.contrib.auth.decorators import [1]
The permission_required decorator is imported from django.contrib.auth.decorators to check user permissions.
Complete the code to require the 'polls.change_poll' permission on the view.
@permission_required('[1]') def edit_poll(request): pass
The permission string must match the app label and permission codename exactly. Here, 'polls.change_poll' requires change permission on polls.
Fix the error in the decorator usage to allow raising 403 error if permission is missing.
@permission_required('polls.change_poll', [1]=True) def edit_poll(request): pass
The correct keyword argument is raise_exception=True to raise a 403 error if permission is denied.
Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.
{word: [1] for word in words if [2]The dictionary comprehension maps each word to its length using len(word). The condition filters words with length greater than 3 using len(word) > 3.
Fill all three blanks to create a dictionary comprehension that maps uppercase words to their lengths only if length is greater than 3.
{ [1]: [2] for word in words if [3] }The keys are uppercase words using word.upper(). The values are lengths with len(word). The condition filters words longer than 3 characters.