答案 0 :(得分:0)
型号:
from django.db import models
class Item(models.Model):
"""Item model."""
title = models.CharField(
max_length=255,
null=True,
blank=True
)
url = models.TextField(
null=False,
blank=False
)
active = models.BooleanField(
default=False
)
class Meta(object):
"""Meta options."""
def __str__(self):
return self.title
管理:
from django.contrib import admin
from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _
from .models import Item
@admin.register(Item)
class ItemAdmin(admin.ModelAdmin):
"""Item admin."""
list_display = (
'id',
'title',
'url',
'active',
'combined',
)
def combined(self, obj):
"""Combined data.
:return:
"""
return format_html(
'''
{}<br/>
{}<br/>
{}
''',
obj.title,
obj.url,
obj.active
)
combined.short_description = _("Combined data")