【发布时间】:2020-01-16 10:11:45
【问题描述】:
我正在使用 Django rest 框架 rest-auth 进行登录和注册。但我不想使用可浏览的 API 作为我的 UI。我正在构建自己的表单。
所以我正在使用这样的自定义登录网址:
path('rest-auth/customlogin', CustomLoginView.as_view(), name='rest_login'),
其中CustomLoginView 定义为:
class CustomLoginView(LoginView):
def get(self, request):
return render(request, "api/test_template.html")
现在在test_template.html,我想要两个输入字段:email 和password。如果我没有用模板覆盖,则显示在可浏览 API 中的相同字段。
我不确定如何将请求数据放入模板。 (如果电子邮件和密码字段驻留在请求数据中,是否正确?)
test_template.html
{% block content %}
<div class="row">
<h3>Login</h3><hr/>
{# I am not sure how to use input fields here where the data inputted goes in the email and password rest-auth fields#}
</div>
{% endblock %}
【问题讨论】:
标签: django django-templates django-rest-auth django-request