Currently, I am working on a project where I aim to showcase a user's code. My approach involves utilizing Django's forms. However, upon submitting the form, the whitespace and line breaks do not seem to be preserved in the output.
I would greatly appreciate any assistance you can provide!
# Here is an example of my form
class VigenereCipherDiscussForm(forms.ModelForm):
class Meta:
model = VigenereCipherDiscuss
fields = ['text', 'share']
widgets = {
"text": forms.Textarea(attrs={"class":"form-control", "rows":4}),
"share": forms.Textarea(attrs={"class":"form-control", "rows":5, "placeholder": "Enter your cipher text or code here to share with others"})
}
# (stackoverflow retains the line breaks, nicely indents the "class Meta")
If I input this code:
x = 2
if x == 2:
return "2"
else:
return None
# I wish for this code to be displayed in the exact format as it is right now!
Despite this, when using Django, the outcome I receive is:
x=2 if x==2: return "2" else return None