Basic способ сделать это в models.py
, пример:Django: как работают allow_tags и short_description?
class Foo(models.Model):
title = models.CharField(max_length=200)
...
def custom_tag(self):
return ('custom: %s' % self.title)
custom_tag.allow_tags = True
custom_tag.short_description = _("Custom Tag")
или, если внутри файла admin.py
;
class FooAdmin(admin.ModelAdmin):
list_display = ['title', 'custom_tag', ...]
...
def custom_tag(self, instance):
return ('custom: %s' % instance.title)
custom_tag.allow_tags = True
custom_tag.short_description = _("Custom Tag")
admin.site.register(Foo, FooAdmin)
Мой вопрос, каким образом allow_tags
и short_description
работает? и где я могу найти соответствующую документацию?
Я не нашел его в documentation или также на source code
humbb Я вижу ... большое вам спасибо ... (y) –