Search code examples
pythonpython-3.xdjangodjango-viewsdjango-3.1

Issue while rendering view with Django 3.1.3 using render function that works fine with Django 2.2


#Code of Django View: check Output here!!

def studiolist_page(request,*args,**kwargs):
        studiomaster={'studio_master_key':StudioMaster.objects.all()}
        studiolist_all=StudioDetails.objects.filter(studio_status=10)

        city_query=request.GET.get("cty")
        studio_type_query=request.GET.get("s_type")
        genre_query=request.GET.get("gnre")
        baseprice_query=request.GET.get("price")
        studiolist={'studio_list_key':studiolist_all}
        print(6)

        x=len(studiolist.get('studio_list_key'))
        if x==0:
            y='Sorry!! No Studios Available Here !!'
        else:   
            y=str(x)+' Fresh Studios Served !!'
        messages.success(request,y)
    
        return render(request,'studiomaster/studiocard_list.html',studiolist,studiomaster)

I also have tried changing the template to find if its an issue with html, but the result is same, So I assume that it might be something to do with the View handling itself.

To my surprise this works fine in Django 2.2 but loads html code on the browser when being rendered so the template is being called but the loading has some abnormal behaviour .

Any help here is greatly appreciated.


Solution

  • Its was the context being passed that was incorrect and seems like django 3.1 was treating that as error!

    Making amendments to the context and passing a single context dict solved the issue.