Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

344
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda