58👍
✅
You can display a property that returns a truncated version of your field’s value in your ModelAdmin class. Leveraging the built-in template filters makes this easy.
from django.template.defaultfilters import truncatechars # or truncatewords
class Foo(models.Model):
description = models.TextField()
@property
def short_description(self):
return truncatechars(self.description, 100)
class FooAdmin(admin.ModelAdmin):
list_display = ['short_description']
3👍
In Your Admin.py File :
class ApplicationAdmin(admin.ModelAdmin):
list_display = ['titl1','title2'] # titl1 is behalf of title1
def titl1(self, obj):
return obj.title1[:100]
- [Django]-Django search fields in multiple models
- [Django]-No module named django but it is installed
- [Django]-How to model a postal address
Source:stackexchange.com