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:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user