Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
How to count how many times is finished function in django?

I have created a function in Django with the purpose that users download files after they fill some form. I want to count how many times is downloaded a file, now how many times is called function. And I want to show that number on my site. How do I do this?

This is my function...

def Only(request):
    page_title = 'Title'
    if request.method == "POST":
        form = Form(request.POST, request.FILES)
        if form.is_valid():

            newdoc = request.FILES['file']
            #some tasks

            response = HttpResponse(
                output, content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
            response['Content-Disposition'] = 'attachment; filename=%s' % filename
            return response
    else:
        form = Form()
    return render(request, 'only.html', { 'form': form, 'page_title':page_title })
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You should create a new integer field in the table where the information of this form is saved. Then when someone fills the form and downloads the file you should update it with +1.

To show this field, first you should create a new post (or get) method to get the field value, and then, you should call this method when you load the page.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!