[Fixed]-Why does render_to_response work even if it does not match the url in urls.py?

1๐Ÿ‘

I think there is some confusion there. render_to_response is being used once the URL has been matched and you are inside the view which is serving the URL.

This is the definition of render_to_response:

render_to_response(template_name, context=None, context_instance=_context_instance_undefined, 
                   content_type=None, status=None, dirs=_dirs_undefined, using=None)

In your case:

return render_to_response('scanner_times.html',
                    {'tickets': tickets,
                    'current_scanner':current_scanner,
                    'date_count':date_count,
                    'sorted_date_count':sorted_date_count},
                      context_instance=RequestContext(request))

here, your template is 'scanner_times.html' and then you have the context dict and then you have the context_instance.

This function will pass this context into the template, render the 'scanner_times.html' and return it.

It has nothing to do with the urls at this moment.

๐Ÿ‘คAKS

Leave a comment