简体   繁体   中英

Django admin. Text does not fit into manytomany field widget

Inside my django admin, I have a many-to-many field in which I want to fit a string.字符串不适合该字段

Is there any way to fix this?

Create a template base_site.html in templates/admin directory with the following content:

{% extends "admin/base.html" %}
{% load static %}

{% block title %} {{ title }} | {{ site_title|default:_('Django site admin') }}

{% endblock %}

{% block extrastyle %}
<link rel="stylesheet" href="{% static 'admin.css' %}">

{% endblock %}

After that create css file in your static directory like admin.css with following styles:

select > option {
white-space: pre-line;
margin-bottom: 20px;
border: 1px solid black;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM