Skip to content

Instantly share code, notes, and snippets.

@NiMeDia
NiMeDia / forms.py
Created September 17, 2020 09:46
Django textarea with default value (quick&dirty)
from django import forms
class TextareaWithValueHandling(forms.Textarea):
"""
Ugly hack to get a default value preset within a textarea. (not supported by django)
This template renders widget.attrs.value within the textarea body if there is no real value
"""
template_name = 'form/widget/textarea_with_value_handling.html'
class TheForm(forms.Form):