1
0
mirror of https://github.com/django/django.git synced 2025-10-27 23:56:08 +00:00

Fixed #8627 -- Prevented textareas to swallow first newline content

Browsers consider the first newline in textareas as some display
artifact, not real content. Hence they are not sending it back to
the server. If we want to keep initial newlines, we have to add one
when we render the textarea.
Thanks bastih for the report and initial patch.
This commit is contained in:
Claude Paroz
2012-11-05 20:27:06 +01:00
parent 39ec43b478
commit 78f66691ee
7 changed files with 52 additions and 3 deletions

View File

@@ -403,7 +403,7 @@ class Textarea(Widget):
def render(self, name, value, attrs=None):
if value is None: value = ''
final_attrs = self.build_attrs(attrs, name=name)
return format_html('<textarea{0}>{1}</textarea>',
return format_html('<textarea{0}>\r\n{1}</textarea>',
flatatt(final_attrs),
force_text(value))