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

373
Visualizações
How to disable cache on Django?

I have a problem with my first django app and I can not find the solution. I send this to my controller:

http://localhost:8000/fun1_get_data/?param1_qty=10

The controller:

@never_cache
def func1_get_data(request):
  result = request.GET['param1_qty']
    return HttpResponse(json.dumps(result), content_type = "application/json")

Only return the same parameter...very easy...but doesn't work.Only works the first time after restart de server or 'save changes' on archive .py.

The first time OK:

http://localhost:8000/fun1_get_data/?param1_qty=10
10

And then....

http://localhost:8000/fun1_get_data/?param1_qty=999
10

panic!!


Extra: the template:

url(r'^func1_get_data/', controlador.func1_get_data)
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Use it like this:

@cache_control(max_age=0, no_cache=True, no_store=True, must_revalidate=True)
def view(request):
    ...
over 4 years ago · Santiago Trujillo Relatório

0

Go to your Django project and open the urls.py file - Import the cache decorator

from django.views.decorators.cache import never_cache

Use it as function wrapper instead of view decorator

path('', include('home.urls')),
path('', include('blog.urls','blog')),
path('ajax/next-page/', never_cache(views.load_more.as_view()), name='next-page'),

It works for me hope so it also for you.

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