8👍
✅
This is happening because request.method == 'POST'
is True (first condition passes) but form.is_valid()
is False (second nested condition fails), which means the final return after the else is run but ctxt is not defined.
Perhaps you intended that final return to be indented as a part of the else
clause?
Source:stackexchange.com