【发布时间】:2018-11-11 05:18:41
【问题描述】:
现在我被困在两件事之间:要么我有一个有效的登录表单,但并不完全是你所说的视觉吸引力,另一个是看起来完美但没有任何作用的登录表单。 (我很了解情况)
如图所示,顶部的那个显然很漂亮(讽刺*),但我希望底部的丑陋的那个起作用。
对于顶部,我只使用了{{ form }} 标记,并且在某一时刻我的代码看起来像这样:
<form method='POST' action='' enctype='multipart/form-data'>{% csrf_token %}
{{ form.username.label_tag }}
{{ form.username }}
{{ form.password.label_tag }}
{{ form.password }}
<input type='submit' class='btn btn-primary btn-block' value='{{ title }}' />
</form>
但这又一次没有给我想要的外观。截至目前,为了让非功能性(但漂亮)的表单查看底部,我正在使用bootstrap template signin 的代码(我的基本模板中包含的signin.css)。这就是我的 form.html 现在的样子:
{% extends 'accounts/base.html' %}
{% block main_content %}
<div class="container">
<div class='col-sm-6 col-sm-offset-3'>
<form method='POST' action='' enctype='multipart/form-data' class="form-signin">{% csrf_token %}
{{ form}}
<h2 class="h3 mb-3 font-weight-normal">Please Sign In</h2>
<input type="username" id="inputUsername" class="form-control" placeholder="Username" required autofocus>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<input type='submit' class='"btn btn-lg btn-primary btn-block' value='{{ title }}' />
</form>
</div>
</div>
{% endblock %}
我已经看到另一个 StackOverflow 帖子 such as this one 并尝试安装 django-widget-tweaks 但由于我使用的是 cloud9-ide 它没有工作
所以,如果有一种方法可以让我以某种方式在我的 Html 中实现表单标签或成功下载 django-tweaks,请告诉我,我将不胜感激。
提前致谢。
【问题讨论】:
-
link是什么意思?您想以自己的方式使用 html 中的表单吗? -
感谢@seuling 的回复,很抱歉我第一次没有说清楚。我的意思是,我想让 html 输入字段(漂亮的)成为连接到我的数据库和登录的功能,就像我的
/admin/页面一样。使用{{ form }}有效,但正如您所见,它看起来不像底部的引导程序。 -
可以上传使用
{{ form }}的结果吗?你可以在浏览器中看到。 (即开发工具) -
我认为它不能很好地工作,因为它没有引导类,对吧?然后你就可以在表单中添加类
标签: python html django twitter-bootstrap