任何人都可以帮助我在同一页面垂直制作两列表格。我也附加了编码。我的问题是如何在form.py中编写两个表单以及如何在模板中进行更改(登录) .html)使2个表格显示成两列?请帮帮我.. 提前谢谢!
class Login(AuthenticationForm):
region = forms.ChoiceField(label=_("Region"), required=False)
username = forms.CharField(label=_("User Name"))
password = forms.CharField(l![enter image description here][2]abel=_("Password"),
widget=forms.PasswordInput(render_value=False))
t= [('http:google.com','Google'),('http://kent.com','University of Kent')]
FederatedLogin = forms.ChoiceField(label= _("Select one of the third party "),choices= t)
tenant = forms.CharField(required=False, widget=forms.HiddenInput())
login.html
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block modal-header %}
{% trans "Log In" %}
{% endblock %}
{% block modal_class %}
login
{% if hide %}
modal hide
{% endif %}
{% endblock %}
{% block form_action %}{% url 'login' %}{% endblock %}
{% block autocomplete %}{{ HORIZON_CONFIG.password_autocomplete }}{% endblock %}
{% block modal-body %}
<fieldset>
{% if request.user.is_authenticated and 'next' in request.GET %}
<div class="control-group clearfix error">
<span class="help-inline"><p>{% trans "You don't have permissions to access:" %}</p>
<p><b>{{ request.GET.next }}</b></p>
<p>{% trans "Login as different user or go back to" %}
<a href="{% url 'horizon:user_home' %}">{% trans "home page" %}</a></p>
</span>
</div>
{% endif %}
{% if next %}<input type="hidden" name="{{ redirect_field_name }}" value="{{ next }}" />{% endif %}
{% include "horizon/common/_form_fields.html" %}
</fieldset>
{% endblock %}
{% block modal-footer %}
<button type="submit" class="btn btn-primary pull-right">{% trans "Sign In" %}</button>
{% endblock %}
答案 0 :(得分:0)
我不在python中编码,但这听起来像一个带有css答案的问题。如果将每个表单放在自己的DIV中并为每个表单分配一个类(两个不同或一个,共享),并将css float设置为“left”,则它们应该彼此相邻排列。
需要注意两点:如果DIV太宽,则第二种形式不会拉到第一种形式的右侧。也许使用%值宽度格式化它们将保护您免受该选项的影响。其次,在第二个表单之后,您可能需要在DOM中的下一个对象上显式设置float to none。我不知道CSS3是否不再需要“重置”。