I'm using Django Messaging framework to send additional data on the validation error:
def clean_X(self):
xuser_id = self.cleaned_data['xuser_id']
if xuser.objects.filter(xuser_id=xuser_id).exists():
available_now = {"available" : ["example","hello","ahc","sdcsd"]}
messages.error(self.request, message = available_now,extra_tags="available_ids")
raise forms.ValidationError('Sorry! User ID "%(xuser_id)s" is already taken, Please try another or chose one from following:', params={"xuser_id" : xuser_id})
return xuser_id
The message is converted as a string when tried to access in the template: like
"{"available" : ["example","hello","ahc","sdcsd"]}"
making difficult to access programmatically i.e message.available
How can i send a json directly to the template using Django-Messages. My intention is here, not just to display a message rather make available-id
's clickable (like the one in gmail auto-suggestion of username)
Thanks!