title: Include a pdf file in urls in Django
body: <p>I've a pdf file in one of my <code>main project</code> directory. How should I add this file in the main urls.py file so as to link this file in <code>&lt;a href&gt;</code> tag.</p>
  <p><strong>EDIT</strong></p>
  <p>I get 2 dates, start and end date, via AJAX. I process the data b/w those 2 dates, generate a report and then returns an HttpResponse. The PDF report is now saved in my main project directory. Now I get a response back in AJAX. So, now how should I process the response in the success function, sent back from the sever and open a PDF file.</p>
  <p>Thanks.</p>
  <p><strong>jQuery</strong></p>
  <pre><code>$(function() {
    $(&quot;#report_submit&quot;).click(function(){
        $.ajax({
        type : &quot;POST&quot;,
        url: &quot;/reports/&quot;,
        data : { 'start_date' : $(&quot;#startDate&quot;).val() , 'end_date' : $(&quot;#endDate&quot;).val() },
        success : function(result){
  
        },
  
        error : function(result){
        }
      });
  
    });
  });
  </code></pre>
  <p><strong>Django view code</strong></p>
  <pre><code>def generate_report(request):
      ctx = {}
  
  
  
  if request.is_ajax():
          if request.POST.has_key('start_date'):
              start_date = datetime.strptime(request.POST[ 'start_date'] , '%m/%d/%Y')
              end_date = datetime.strptime(request.POST[ 'end_date'] , '%m/%d/%Y')
              
              ......
              # PDF GENERATED in MAIN PROJECT DIRECTORY
  
              with open(os.path.join(os.path.dirname(__file__),'../../../../gui','Report.pdf')) as pdf:
                  response = HttpResponse(pdf.read(), content_type='application/pdf')
                  response['Content-Disposition'] = 'inline;filename=Report.pdf'
  
                  return response  # so, now when I send a response back, how should I process it in AJAX success function?
              pdf.closed
  
  
      return render(request, 'generate_report/reports.html', ctx)
  </code></pre>