I have a toast for displaying errors.
$.toast({
text: '{{ form.non_field_errors }}'
})
But it is returning a html format. so i am getting an error.

But i would like to get text only from {{ form.non_field_errors }}. How do i do that?
You can use the .as_text() method, on the non_field_errors:
$.toast({
text: '{{ form.non_field_errors.as_text }}'
})
Note however that in order to make this more safe, you better JSON-ify this, and furthermore mark the output as safe.
You thus better do some processing in the view:
from json import dumps as jdumps
def some_view(request):
some_form = ModelForm(request.POST)
errors = jdumps(some_form.non_field_errors().as_text())
return render(request, 'some_template.html', {'errors': errors})
and in the template render this as:
$.toast({
text: {{ errors|safe }}
})