环境
Python 3.7.6
Django 2.2.16
Django-simpleui 2020.9.26
操作
示例 admin.py
@admin.register(Test)
class TestAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
temp1 = 'Yudelei.com'
temp2 = 'Author: Shanks'
hhf = '\n'
html = temp1 + hhf + temp2
obj.html = html
obj.save()
重写/修改 fieldset.html
PyCharm -> ctrl + shift + f (全局搜索) -> field.is_readonly -> 找到位于
venv\Lib\site-packages\simpleui\templates\admin\includes\fieldset.html
的如下代码:
{% if field.is_readonly %}
<div class="readonly"> {{ field.contents }} </div>
{% else %}
{{ field.field }}
{% endif %}
修改为:
{% if field.is_readonly %}
<div class="readonly"> {{ field.contents|linebreaksbr }} </div>
{% else %}
{{ field.field }}
{% endif %}