Django SetPasswordForm 不呈现任何内容

Django SetPasswordForm doesn't render anything

Django 的 SetPasswordForm 没有呈现任何内容,请帮忙。

这是我得到的:

views.py

from django.contrib.auth.forms import SetPasswordForm

@login_required
def profile_security(request):
    template = "profiles/profile_security.html"
    form = SetPasswordForm
    print("form.base_fields: %s" % form.base_fields)
    context = {"profile_index_active": "active", "underline_security": "text-underline", "form": form}
    return render(request, template, context)

html

   <form method="post">{% csrf_token %}
         {{ form.as_p }}
   </form>

也试过这个html

            <form method="post">{% csrf_token %}
                <div class="form-group field-password1">
                    {{ form.new_password1.errors }}
                    <label for="id_new_password1">New Password</label>
                    {{ form.new_password1 }}
                </div>
                <div class="form-group field-password2">
                    {{ form.new_password2.errors }}
                    <label for="id_new_password2">Repeat New Password</label>
                    {{ form.new_password2 }}
                </div>
                <div class="form-group">
                    <input class="btn btn-success text-uppercase w-100" type="submit" value="Guardar nueva contraseña">
                </div>
            </form>

它确实正确地打印了字段:

form.base_fields: {'new_password1': <django.forms.fields.CharField object at 0x7f49174e2790>, 'new_password2': <django.forms.fields.CharField object at 0x7f49174e2940>}

但它不呈现任何内容。我做错了什么?

SetPasswordForm class 需要用户实例

form = SetPasswordForm(request.user)