URL redirect issue in python using Django framework

44 Views Asked by At

I am working on Python using the Django framework. During setting URLs for my web application, I am facing some problems. I have redirect code return HttpResponseRedirect('/{}-meters-to-{}/'.format(value, unit)). This is not appending value URL some time but the output is showing.

path('meters-to-centimeters/', views.functon1, name='convert_m_cm'),# landing page url
path('meters-to-millimeters/', views.function1, name='convert_m_mm'),# landing page url
path('<str:data>-meters-to-<str:to_units>/', views.function1_views, name='m_conversion_views'),# details page /output page url 

[I gave input as 5 and select inches unit but URL is not related to that.]. Kindly guide me in this problem.

            if 1.0 <= temp_value <= 200.0:
                for inc_m in numpy.arange(temp_value, float(temp[0]) + 6, 0.1):
                    if inc_m.is_integer():
                        inc_m = int(inc_m)
                    else:
                        inc_m = float(inc_m)
                    s1 = round_functions(temp_value, inc_m)
                    inputs = str(s1) + '-' + temp[1] + '-to-' + temp[-1]
                    exit_or_not = MConversion.objects.filter(unit_m=inputs).count()
                    if exit_or_not == 0:
                        for inc_m in numpy.arange(s1, float(temp[0]) + 6, 0.1):
                            if inc_m.is_integer():
                                inc_m = int(inc_m)
                            else:
                                inc_m = float(inc_m)
                            s1 = round_functions(temp_value, inc_m)
                            inputs = str(s1) + '-' + temp[1] + '-to-' + temp[-1]
                            if MConversion.objects.filter(unit_m=inputs).count() == 0:
                                results_km_others = m_others_convert(inputs)
                                if results_km_others:
                                    # saving data in db code
                                    
                                else:
                                    continue
                        value = temp[0]
                        unit = temp_unit
                        return HttpResponseRedirect('/{}-meters-to-{}/'.format(value, unit))
0

There are 0 best solutions below