I have a flash file which calls a url like: http://test.com/savethis/123456/
I just want my view to save "123456" in the database and return nothing.
After saving the values what do I do? If I redirect it it changes the page and that's bad. I could render a page, but I don't want to. I just want it to end and not throw any errors.
Make sure your URLConf points to your desired view function, and write something like:
from django.http import HttpResponse
from my_models import MyModel
def myview(request, number):
my_model = MyModel(my_field = number)
my_model.save()
return HttpResponse()
The empty HttpResponse at the end there sends back a status code of 200 OK so that the browser or other server that connects to your endpoint knows the request was completed.
It sounds like you're in a view function, which means someone's issued an HTTP request for something, which you have to respond to, so you can't just do nothing.
Either return an error code, or return an HttpResponse
. You could just return an empty OK response (i.e. return HTTP response 200):
from django.http import HttpResponse
def myview(request):
return HttpResponse()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With