5👍
✅
Here’s a snippet of HTML for the column containing the attribute headline
from one of my admins:
<th scope="col" class="sortable column-headline">
<div class="text"><a href="?o=2.4.-5">Headline</a></div>
<div class="clear"></div>
</th>
You could set the width of that in CSS like this:
th.column-headline {
width: 10000000px;
}
1👍
Here’s the lazy person’s method to extend a column width in the django admin without doing a css override.
from django.utils.html import format_html
class MyModelAdmin(admin.ModelAdmin):
...
def get_column_extended_field(self, obj):
result = ''
field_value = obj.field_value
if field_value:
spaces = ' ' * 75
result = format_html('{result}<br/>' + spaces, result=field_value)
return result
get_column_extended_field.short_description = _('Extended Field')
- [Django]-Get models ordered by an attribute that belongs to its OneToOne model
- [Django]-Django: Overriding form save?
- [Django]-Return object when aggregating grouped fields in Django
- [Django]-A simpler i18n for Python/Django
- [Django]-How to display the last login date and time on the users list on the django admin site?
Source:stackexchange.com