Django: Add Link in View

In my Django project, I have an Ajax request that returns a JSON response. When there is an error, I would like to present the error text, as well as a link. Something like “There was a problem, please click here”. I don’t know how to get the link in the JSON, however. Maybe I am thinking about this wrong – any help is appreciated!

Ajax call:

$.ajax({method: 'POST', url:'/update_count/' + meals, data:{csrfmiddlewaretoken: "{{ csrf_token }}", 'auto-update': auto_update}}).done(function(data) {
            if(data['type']  === 'error'){
                 $('#error-message').html(data['message'])
            }

View

return JsonResponse({'type': 'error', 'message': 'Only registered users can use this feature. Please click ???????? for more information.'})


Source: python

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.