gpt4 book ai didi

python - 在 "same line"上显示 Django 表单字段

转载 作者:行者123 更新时间:2023-11-28 22:30:08 24 4
gpt4 key购买 nike

我想在同一行显示两个表单域,而不是一个接一个地显示。

目前,我得到:

Choice a theme :
. Datasystems
. Cameroun

但我想显示这种形式:

Choice a theme:
. Datasystems . Cameroun

我的 .html 文件 看起来像:

{% extends 'Base_Configurations.html' %} 
{% load staticfiles %}
{% load static %}
{% block title %}
<h3> <span class="glyphicon glyphicon-file"></span> Choix du thème DatasystemsEC </align> </h3>
{% endblock %}

{% block content %}

<form class="form" method='POST' action=''> {% csrf_token %}
<br></br>
{{ form }}
<br></br>
<input class="button" type="submit" value="Valider le thème" />
</form>

{% endblock %}

我还有一个 .css 文件:

.form-fields {
border-radius: 4px;
margin-right: auto;
width:50%;
background-color: #f5f5f5;

}

.form {
padding-left:8vw;

}

label {
width: 35%;
border-radius: 8px;
margin-bottom: -20px;
list-style: none;
}

目前,我没有找到解决问题的方法。我查看了一些教程或 StackOverflow 问题,但到目前为止什么都没有。

您对这种处理有什么想法吗?

最佳答案

您可以通过Bootstrap 网格系统来做到这一点。正如问题中所建议的那样,每行将有两个字段。

试试这个:

  <div class="container">
<div class="row">
{% for field in form %}
<div class="col-sm-6">
<b>{{ field.label_tag }}</b> - {{ field }}
</div>
{% endfor %}
</div>
</div>

关于python - 在 "same line"上显示 Django 表单字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42530325/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com