Reputation: 202
I created a model in django like below.
class MyDB(models.Model):
pub_date = models.DateTimeField(_("Date added"),editable=True, auto_now_add=False)
title = models.CharField(max_length=256,blank=True,null=True)
text = models.TextField(_("Text"))
Then I got the model and mapped into Frontend.
context['mydb'] = MyDB.objects.all()
let plots = [];
{% for d in mydb %}
var id = '{{ d.id }}';
var title = '{{ d.title }}';
var text = '{{ d.text }}';
console.log(text)
{% endfor %}
When the text contains 'enter' in string. it raise error.
Upvotes: 0
Views: 22
Reputation: 179
Please try to replace ' with ` (backtick), it should fix your issue (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#multi-line_strings)
Upvotes: 1