How to use Httpresponse in view in django while using Ajax -


i using this

def ajax_create( request ):     if request.is_ajax():              form = sourceform()              template = 'ajax_form.html'             data = {                 'form': form,             }             return render_to_response( template, data,                 context_instance = requestcontext( request ) ) 

i error

ajax_create didn't return httpresponse object

perhaps if request.is_ajax(): returning false, if that's entire view function?

typically, should follow pattern when making django view functions:

def my_view(request):     if request.method == 'post':         form = myform(data=request.post, files=request.files)         if form.is_valid():             # form...     else:         initial = {...}         form = myform(initial=initial)     context = {'form':form, ...}     return render_to_response('path/to/template.html', context, context_instance=requestcontext(request)) 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -