Answer the question
In order to leave comments, you need to log in
How to insert html tags (CSS) in response from Django?
Good afternoon! I wanted to have a double column in the admin panel on the model instance selection page - in one column two values \u200b\u200bdisplayed at once, like this:
╔═══════════╦═════════════╦══════════════════════════════════════╗
║ Предмет ║ Категория ║ Количество взятых / Общее количество ║
╠═══════════╬═════════════╬══════════════════════════════════════╣
║ Предмет 1 ║ Категория 1 ║ 123 / 155 ║
╚═══════════╩═════════════╩══════════════════════════════════════╝
class ItemAdmin(admin.ModelAdmin):
def get_numbers(self):
return str(self.number_taken)+ '<span style="color: #6161ff">/</span>' + str(self.number_full)
get_numbers.short_description = 'Количество взятых <span style="color: #6161ff">/</span> общее количество'
list_display = ['name', 'category', get_numbers]
Answer the question
In order to leave comments, you need to log in
Use mark_safe which will disable escaping for the given string in the template.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question