mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #22241 -- Selectively added line breaks in admin read-only fields
When content is supposed to contain HTML, we do not try to add line breaks in read-only contents. Thanks Alexander Todorov for the report.
This commit is contained in:
@@ -15,6 +15,7 @@ from django.conf.urls import patterns, url
|
||||
from django.forms.models import BaseModelFormSet
|
||||
from django.http import HttpResponse, StreamingHttpResponse
|
||||
from django.contrib.admin import BooleanFieldListFilter
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.six import StringIO
|
||||
|
||||
from .models import (Article, Chapter, Child, Parent, Picture, Widget,
|
||||
@@ -407,8 +408,8 @@ class PrePopulatedPostAdmin(admin.ModelAdmin):
|
||||
class PostAdmin(admin.ModelAdmin):
|
||||
list_display = ['title', 'public']
|
||||
readonly_fields = (
|
||||
'posted', 'awesomeness_level', 'coolness', 'value', 'multiline',
|
||||
lambda obj: "foo"
|
||||
'posted', 'awesomeness_level', 'coolness', 'value',
|
||||
'multiline', 'multiline_html', lambda obj: "foo"
|
||||
)
|
||||
|
||||
inlines = [
|
||||
@@ -427,6 +428,10 @@ class PostAdmin(admin.ModelAdmin):
|
||||
def multiline(self, instance):
|
||||
return "Multiline\ntest\nstring"
|
||||
|
||||
def multiline_html(self, instance):
|
||||
return mark_safe("Multiline<br>\nhtml<br>\ncontent")
|
||||
multiline_html.allow_tags = True
|
||||
|
||||
value.short_description = 'Value in $US'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user