django drf登录模板 [英] django drf login template
本文介绍了django drf登录模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我扩展了DRF的登录模板
I extend the login template of DRF
{% extends "rest_framework/login_base.html" %}
{% block branding %}
<h3 style="margin: 0 0 20px;">My site</h3>
{% endblock %}
带有urls.py:
urlpatterns = [
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^login', login, template_name, name='login'),
url(r'^logout', logout, template_name, name='logout'),
...
一切正常,除非连接失败:DRF重定向到 http://127.0. 0.1:8000/api-auth/login/代替 http://127.0.0.1:8000/login/,并且未使用我的扩展模板.因此,我失去了"Django REST framework"标题的网站名称.
Everything works well except if the connection fails: DRF redirect to http://127.0.0.1:8000/api-auth/login/ instead of http://127.0.0.1:8000/login/ and my extended template is not used. So I lose my site name for "Django REST framework" title.
致谢
推荐答案
将模板放入templates/rest_framework/
和
urlpatterns = [
url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')),
这篇关于django drf登录模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文