Bird
0
0

You added @xframe_options_exempt decorator to a view but clickjacking protection still blocks framing. What is the likely cause?

medium📝 Debug Q14 of 15
Django - Security Best Practices
You added @xframe_options_exempt decorator to a view but clickjacking protection still blocks framing. What is the likely cause?
AThe decorator disables CSRF protection, causing conflict
BYou forgot to add <code>XFrameOptionsMiddleware</code> in settings
CYou must also set <code>X_FRAME_OPTIONS = None</code> in settings
DThe decorator only works if middleware is enabled
Step-by-Step Solution
Solution:
  1. Step 1: Understand decorator dependency

    The @xframe_options_exempt decorator only works if the XFrameOptionsMiddleware is active.
  2. Step 2: Identify cause of blocking

    If middleware is missing or disabled, the decorator has no effect; if middleware is enabled, decorator exempts the view.
  3. Final Answer:

    The decorator only works if middleware is enabled -> Option D
  4. Quick Check:

    Decorator needs middleware enabled [OK]
Quick Trick: Decorator requires middleware to function [OK]
Common Mistakes:
MISTAKES
  • Assuming decorator works without middleware
  • Thinking CSRF relates to clickjacking decorator
  • Trying to disable header via settings incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes