django-crispy-form 不渲染提交按钮也不渲染表单动作属性

django-crispy-form does not render the submit button and does not render the form action attribute

我正在尝试使用 django-cripsy-for 来自定义我的表单。但似乎 crispy form 以某种方式没有呈现提交按钮和表单操作属性。 这是我正在渲染表单的模板。(login.html)

{% extends '_base.html' %}
{% block content %}
{{ login_error_message }}

    {% load crispy_forms_tags %}
    {% crispy form form.helper  %}

{% endblock %}

这里是景色

class LoginView(FormView):
    form_class = LoginForm
    template_name = "login.html"
    success_url = reverse_lazy('home')

    def form_valid(self, form):
        email = form.cleaned_data['email']
        password = form.cleaned_data['password']
        referrer = self.request.POST.get('referrer')
        user = authenticate(email=email, password=password)

        if user is not None:
            # if user.is_active:
            login(self.request, user)
            if referrer !="":
                self.success_url = referrer
            return super(LoginView, self).form_valid(form)
        else:

            return render(self.request, "login.html", {'form': form, 'login_error_message': "Invalid username and password."})

    def get_context_data(self, **kwargs):
        result = super(LoginView, self).get_context_data( **kwargs)
        param = self.request.GET.get('next', '')
        result.update({'param': param})
        return result

这是我的表格class

class LoginForm(forms.Form):
    def __init__(self, *args, **kwargs):
        super(LoginForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_id = 'id-form'
        self.helper.form_class = 'form-horizontal'
        self.helper.form_method = 'post'
        self.helper.form_action = 'login'

    email = forms.EmailField(max_length=100)
    password = forms.CharField(max_length=100)

我错过了什么?请帮忙。

来自 Django 文档 (https://docs.djangoproject.com/en/1.8/topics/templates/):

{# this won't be rendered #}

出于某种原因,您将表单输出为模板中的一系列 Django 注释。为什么?

关于缺少提交按钮: 您必须先添加它!

self.helper.add_input(Submit('submit', 'Submit'))

Fundamentals documentation

的第4个清单中可以看出