Changed "dict.setdefault" to "if x in dict" pattern so that get_form() would not be called unnecessarily, specifically in the case where FormMixin.form_invalid() calls get_context_data() with the current form.