Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

178
Vistas
Django render not working when redirected from another view

I have two views as follows

def home(request):
    levels = levelData.objects.all()
    context ={
            "levels" : levels
    }
    print "abcde"
    return render(request, 'home.html', context)

and the other one

def create(request):
    if request.method == "POST":
        # doing something with data with saveData as variable of model type
        saveData.save()
        return redirect('home')
    return render(request, 'create.html')

Now, inside the create view, I wish to redirect to home view after saving data. Redirect is working fine and it's being redirected to home as the print statement in home view is executed and "abcde" is printed in terminal. But, home.html does not get rendered and it remains on create.html. Also, the url doesn't change.

This is home view in my urls.py

url(r'^$', home, name='home'),

What am I doing wrong?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If you are posting through AJAX, you cannot do that.You have to do like

window.location.href = '/redirecturl/'

in AJAX success callback.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda