<form method="POST" class="container is-responsive">
{% csrf_token %}
<h1><font color="black">Log in</font></h1>
<label for="username"><font color="black"><b>Email</b></font></label>
<p><font color="black"> {{ form.username}}</font></p>
<label for="psw"><font color="black">Password</font></label>
<p><font color="black">{{ form.password}}</font></p>
<button type="submit" class="btn">Login</button>
{% if form.errors %}
<p><font color="red"><b>Invalid username or password.</b> Please try again.</font></p>
{% endif %}
</form>
需要为默认的form.username和form.password字段添加占位符
答案 0 :(得分:0)
您可以使用jquery执行此操作。将此标签添加到head标签中。
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" >
$(document).ready(function(){
$("#id_username").attr('placeholder', 'Enter Email Address to continue');
$("#id_password").attr('placeholder', 'Enter password to continue');
});