Not redirecting, but executing everything

Hello I’m trying to redirect after a successful post to another page within the same app and its not working. Whenever I use the developer tools in the browser I can see a preview of the desired template with the correct data and the correct url is being generated in a GET request, if I input it manually it works. I’ve been stuck on this for a day now and would appreciate any help, Thank you.

# This is my views.py


from django.http import HttpResponse, JsonResponse, HttpResponseRedirect
from django.template import loader
from django.shortcuts import get_object_or_404, render, redirect
from django.urls import reverse
import plotly.graph_objs as go
import numpy as np
import json
import requests

# Create your views here.
def solicitud(request):
    if request.method == 'GET':
        url = "http://127.0.0.1:8080/API/"
        response = requests.get(url)

        #print(response.content)
        #print(response.headers)

        if response.status_code == 200:
            posibles_valores = response.json()
            #print(posibles_valores)
            genero = posibles_valores["posibles_valores"]["Genero"]
            ocupacion = posibles_valores["posibles_valores"]["Ocupacion"]
            empresa = posibles_valores["posibles_valores"]["Empresa"]
            antiguedad = posibles_valores["posibles_valores"]["Antiguedad"]
            estado = posibles_valores["posibles_valores"]["Estado"]
            estado_civil = posibles_valores["posibles_valores"]["Estado civil"]

            context = {
                'genero': genero,
                'ocupacion':ocupacion,
                'empresa':empresa,
                'antiguedad':antiguedad,
                'estado': estado,
                'estado_civil': estado_civil
            }
            return render(request, 'components/forms/form-captura_datos_credito.html', context)
        else:
            error_msg = f"Error {response.status_code}: {response.reason}"
            return HttpResponse(json.dumps({"error": error_msg}), content_type="application/json", status=response.status_code)
        
    elif request.method == "POST":

        url = "http://127.0.0.1:8080/API/"  # The URL of your Django REST API endpoint
        headers = {'content-type': 'application/json'}

        data = {
            "Plazo en meses": int(request.POST.get("plazo-en-meses")),
            "Edad": int(request.POST.get("edad")),
            "Numero de contratos previos": int(request.POST.get("contratos-previos")),
            "Ingreso mensual": int(request.POST.get("ingreso-mensual")),
            "% de pago/ingreso": 0.1,
            "Antiguedad": request.POST.get("selector-antiguedad"),
            "Ocupacion": request.POST.get("ocupacion-datalist"),
            "Empresa": request.POST.get("empresa-datalist"),
            "Estado": request.POST.get("estado-datalist"),
            "Estado civil": request.POST.get("selector-estado-civil"),
            "Genero": request.POST.get("selector-genero"),
        }  # The data you want to send in the POST request

        response = requests.post(url, headers=headers, json=data)
        #print(response.content)
        if response.status_code == 200:
            # Success! The API returned a response
            #new_resource_url = response.headers["Location"]  # The URL of the newly created resource
            new_resource_data = response.content.decode()  # The data of the newly created resource in JSON format
            ##########
            new_resource_data = json.loads(new_resource_data)
            new_resource_data['etiquetas'][8] = "pago ingreso"
            new_resource_data = json.dumps(new_resource_data, separators=(',',':'))
            ##########
            #print(new_resource_data)
            new_resource_data = json.dumps(new_resource_data, separators=(',', ':'))
            #print(new_resource_data)
            url = reverse('calificacion', kwargs={'response_data' : new_resource_data})
            #url = request.build_absolute_uri(reverse('calificacion', kwargs={'response_data' : new_resource_data}))

            return HttpResponseRedirect(url)
        else:
            # Oops, there was an error. Handle it here
            error_message = f"Error {response.status_code}: {response.reason}"
            return HttpResponse(json.dumps({"error": error_message}), content_type="application/json", status=response.status_code)
        
def calificacion(request, **kwargs):
        if request.method == "GET":
            response_data = json.loads(kwargs['response_data'])
            #print(response_data)
            '''
            print(type(response_data))
            trace = go.Waterfall(
                name="Calificacion", orientation="h",
                measure=["relative", "relative", "relative", "relative", "relative", "relative","relative", "relative", "relative", "relative", "relative", "relative","total"],
                y=response_data["etiquetas"],
                x=response_data,
                connector = {"mode":"between", "line":{"width":4, "color":"rgb(0, 0, 0)", "dash":"solid"}},
            )

            layout = go.layout(
                title='Calificacion',
                showlegend = True
            )

            fig = go.Figure(data=[trace], layout=layout)

            graph = fig.to_html(full_html=False)
            #print(response_data)
            '''
            return render(request, 'components/charts/charts-waterfall.html', {'response_data': response_data})
        else:
            None```

# This is my urls.py

  from django.urls import path
  from . import views
  
  urlpatterns=[
      path('solicitud/', views.solicitud, name='solicitud'),
      path('calificacion/<str:response_data>/', views.calificacion, name='calificacion'),
  ]```

What is the specific error that you are receiving? Are you getting a 404 or what?

If it’s a 404, what specifically is the url being generated by this line? (If it doesn’t begin with the /, making it an absolute URL, it’s going to be an incorrect reference.)

Hello @KenWhitesell thank you for your response.
I get no error, thats the thing. After I click the submit button on my form, and all both views’ code gets executed nothing happens.
I just get a successfull Http response with the actual URL i need to go to.

Please post your server log for these requests. (Copy/paste the text, please don’t post images.)

My apologies for the picture. Here are the last logs regarding the request.

File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\core\checks\compatibility\django_4_0.py first seen with mtime 1680300416.6372044
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components first seen with mtime 1681256477.6486373
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\partials first seen with mtime 1681256477.6887422
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\charts first seen with mtime 1681256477.6486373
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\forms first seen with mtime 1681322975.1468027
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\charts\charts-apex.html first seen with mtime 1664232116.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\charts\charts-chartjs.html first seen with mtime 1664232116.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\charts\charts-echart.html first seen with mtime 1675105769.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\charts\charts-knob.html first seen with mtime 1664232116.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\charts\charts-sparkline.html first seen with mtime 1664232116.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\charts\charts-waterfall.html first seen with mtime 1681341525.963541
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\charts\grafico_linea.html first seen with mtime 1675118801.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\forms\form-advanced.html first seen with mtime 1674943578.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\forms\form-captura_datos_credito.html first seen with mtime 1681322975.1468027
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\forms\form-editors.html first seen with mtime 1664232141.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\forms\form-elements.html first seen with mtime 1664232141.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\forms\form-mask.html first seen with mtime 1664232141.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\forms\form-uploads.html first seen with mtime 1664232141.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\forms\form-validation.html first seen with mtime 1664232141.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\components\forms\form-wizard.html first seen with mtime 1674944497.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\partials\base.html first seen with mtime 1675202188.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\partials\base2.html first seen with mtime 1674779991.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\partials\content.html first seen with mtime 1664232118.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\partials\footer.html first seen with mtime 1664232118.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\partials\header.html first seen with mtime 1675125551.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\partials\header2.html first seen with mtime 1674780116.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\partials\hori-header.html first seen with mtime 1664232118.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\partials\hori-left-sidebar.html first seen with mtime 1664232118.0
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\partials\left-sidebar.html first seen with mtime 1681259401.6347332
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\templates\partials\right-sidebar.html first seen with mtime 1664232118.0
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0001_initial.py first seen with mtime 1680300414.6221838
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0009_alter_user_last_name_max_length.py first seen with mtime 1680300414.6279335
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\calificador\migrations\__init__.py first seen with mtime 1681256245.503842
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0002_alter_permission_name_max_length.py first seen with mtime 1680300414.6221838
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\admin\migrations\0001_initial.py first seen with mtime 1680300413.889596
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\sessions\backends\db.py first seen with mtime 1680300416.1324308
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\__init__.py first seen with mtime 1680300414.630531
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0007_alter_validators_add_error_messages.py first seen with mtime 1680300414.6279335
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\contenttypes\migrations\0001_initial.py first seen with mtime 1680300414.8772163
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0011_update_proxy_permissions.py first seen with mtime 1680300414.630531
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0010_alter_group_name_max_length.py first seen with mtime 1680300414.630531
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0003_alter_user_email_max_length.py first seen with mtime 1680300414.6221838
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0012_alter_user_first_name_max_length.py first seen with mtime 1680300414.630531
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\admin\migrations\__init__.py first seen with mtime 1680300413.889596
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\contenttypes\migrations\0002_remove_content_type_name.py first seen with mtime 1680300414.8772163
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\contenttypes\migrations\__init__.py first seen with mtime 1680300414.8772163
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\sessions\migrations\0001_initial.py first seen with mtime 1680300416.3450093
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\middleware\clickjacking.py first seen with mtime 1680300416.9550118
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\admin\migrations\0002_logentry_remove_auto_add.py first seen with mtime 1680300413.889596
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\db\migrations\loader.py first seen with mtime 1680300416.7508965
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\sessions\migrations\__init__.py first seen with mtime 1680300416.3450093
File C:\Users\nesto\Desktop\attendo-ia2\attendodemo\attendodemo\wsgi.py first seen with mtime 1681256024.735197
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\db\models\sql\compiler.py first seen with mtime 1680300416.832508
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0004_alter_user_username_opts.py first seen with mtime 1680300414.6221838
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\db\migrations\recorder.py first seen with mtime 1680300416.7697783
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\db\migrations\graph.py first seen with mtime 1680300416.7508965
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0006_require_contenttypes_0002.py first seen with mtime 1680300414.6221838
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\admin\migrations\0003_logentry_add_action_flag_choices.py first seen with mtime 1680300413.889596
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0008_alter_user_username_max_length.py first seen with mtime 1680300414.6279335
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\migrations\0005_alter_user_last_login_null.py first seen with mtime 1680300414.6221838
"POST /calificador/solicitud/ HTTP/1.1" 302 0
"GET /calificador/calificacion/%22%7B%5C%22etiquetas%5C%22:%5B%5C%22Estado%20civil%5C%22,%5C%22Antiguedad%5C%22,%5C%22Numero%20de%20contratos%20previos%5C%22,%5C%22Genero%5C%22,%5C%22base%5C%22,%5C%22Ocupacion%5C%22,%5C%22Empresa%5C%22,%5C%22Estado%5C%22,%5C%22pago%20ingreso%5C%22,%5C%22Edad%5C%22,%5C%22Ingreso%20mensual%5C%22,%5C%22Plazo%20en%20meses%5C%22%5D,%5C%22peso%5C%22:%5B-0.11848400397618986,-0.055735993156156426,-0.049108396853996504,-0.023347987110651086,-0.014767786257382233,0.005985121339703548,0.011149352682468992,0.06396933268572336,0.07806137817475843,0.09831329562876097,0.11425628548404256,0.2759669306176463%5D%7D%22/ HTTP/1.1" 200 33326
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\sessions\serializers.py first seen with mtime 1680300416.1324308
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\staticfiles\storage.py first seen with mtime 1680300416.571603
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\template\context_processors.py first seen with mtime 1680300416.9711423
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\messages\storage\session.py first seen with mtime 1680300415.7140734
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\messages\context_processors.py first seen with mtime 1680300415.7058978
File C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\Lib\netrc.py first seen with mtime 1680018594.797645
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\auth\context_processors.py first seen with mtime 1680300414.3847897
File C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\Lib\shlex.py first seen with mtime 1680018594.908204
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\messages\storage\cookie.py first seen with mtime 1680300415.7140734
File C:\Users\nesto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\django\contrib\messages\storage\fallback.py first seen with mtime 1680300415.7140734

So the post is working and it is redirecting.

The subsequent GET is also working.

Whatever the issue is, this isn’t it.

It is weird. I guess I’ll try it in different systems and see where it gets me.
Thank you very much for your time and expertise.