How do I return a JsonResponse if the post data is bad in tastypie?
<p>For example, client post a card number in data and I use it to fetch the card record from database. If it does not exist, I return a JsonResponse such as:</p>

<p><code>
return JsonResponse({
    success:False,
    msg:'The card does not exsit! Please check the card number.'
    })
</code></p>

<p>If the card does exist, I will use it to filter another record from database and use them togeter to create the obj such as an consumption record.</p>

<p>I read the docs of tastypie but have no idea how to control the HttpResponse that tastypie finally returned.</p>

<p>Assuming you're returning django's <a href="https://docs.djangoproject.com/en/1.10/ref/request-response/#jsonresponse-objects" rel="nofollow">JsonResponse</a>, you can simply return it with appropriate <a href="https://docs.djangoproject.com/en/1.10/ref/request-response/#django.http.HttpResponse.status_code" rel="nofollow">status</a>, just like with <code>HttpResponse</code>.</p>

python django tastypie