I am using django-grappelli as django admin template. But I want to use {{foo|safe}}
for a particular entry from my database which I made using CKeditor, which is being displayed in admin template. I know how to use safe tag in templates but I don't to how to use them in admin site.I want to apply safe
tag to Bio field .Thanks.
Asked
Active
Viewed 867 times
0

Shubham Devgan
- 609
- 6
- 18
1 Answers
2
You could define a new field, which would use mark_safe
:
from django.utils.safestring import mark_safe
class ExampleModelAdmin(admin.ModelAdmin):
base_model = ExampleModel
list_display = (..., 'enter_bio_safe')
def enter_bio_safe(self, obj):
return mark_safe(obj.enter_bio)
enter_bio_safe.short_description = 'Enter bio'

niekas
- 8,187
- 7
- 40
- 58
-
Should be `list_display`, not `fields`. – Daniel Roseman Jul 17 '19 at 10:58
-
yeah it worked after update.Can you explain this code? – Shubham Devgan Jul 17 '19 at 11:01