Fixed #19226 -- Applied linebreaksbr to read-only fields in admin
Thanks shadow for the report, and Melevir and thiderman for the patch.
This commit is contained in:
parent
8c69278764
commit
ec9d6b1122
|
@ -14,7 +14,7 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ field.label_tag }}
|
{{ field.label_tag }}
|
||||||
{% if field.is_readonly %}
|
{% if field.is_readonly %}
|
||||||
<p>{{ field.contents }}</p>
|
<p>{{ field.contents|linebreaksbr }}</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ field.field }}
|
{{ field.field }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -388,7 +388,10 @@ class PrePopulatedPostAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
class PostAdmin(admin.ModelAdmin):
|
class PostAdmin(admin.ModelAdmin):
|
||||||
list_display = ['title', 'public']
|
list_display = ['title', 'public']
|
||||||
readonly_fields = ('posted', 'awesomeness_level', 'coolness', 'value', lambda obj: "foo")
|
readonly_fields = (
|
||||||
|
'posted', 'awesomeness_level', 'coolness', 'value', 'multiline',
|
||||||
|
lambda obj: "foo"
|
||||||
|
)
|
||||||
|
|
||||||
inlines = [
|
inlines = [
|
||||||
LinkInline
|
LinkInline
|
||||||
|
@ -402,6 +405,10 @@ class PostAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
def value(self, instance):
|
def value(self, instance):
|
||||||
return 1000
|
return 1000
|
||||||
|
|
||||||
|
def multiline(self, instance):
|
||||||
|
return "Multiline\ntest\nstring"
|
||||||
|
|
||||||
value.short_description = 'Value in $US'
|
value.short_description = 'Value in $US'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3149,6 +3149,10 @@ class ReadonlyTest(TestCase):
|
||||||
self.assertContains(response, "Very awesome.")
|
self.assertContains(response, "Very awesome.")
|
||||||
self.assertContains(response, "Unkown coolness.")
|
self.assertContains(response, "Unkown coolness.")
|
||||||
self.assertContains(response, "foo")
|
self.assertContains(response, "foo")
|
||||||
|
|
||||||
|
# Checks that multiline text in a readonly field gets <br /> tags
|
||||||
|
self.assertContains(response, "Multiline<br />test<br />string")
|
||||||
|
|
||||||
self.assertContains(response,
|
self.assertContains(response,
|
||||||
formats.localize(datetime.date.today() - datetime.timedelta(days=7))
|
formats.localize(datetime.date.today() - datetime.timedelta(days=7))
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue