Search code examples
pythondjangomodelprocessors

Django cant read variables


I have a problem with django In my views.py i have this

def home(request):
    template = "index.html"
    test = "hello"
    Settings = settings.objects.all()
    return render_to_response(template ,{"Settings" : settings}, context_instance=RequestContext(request))

And in my index.html

{{test}}

But it doesnt return anything Also my model has a field called logo_img if i write

{{ Settings.logo_img }}

Doesnt work either , any ideas ?


Solution

  • To render the test variable with "hello":

    def home(request):
        template = "index.html"
        test = "hello"
        return render_to_response(template, {"test": test})
    

    As long as your templates directory is configured correctly, and index.html is found, this should work. I'm not sure what you are using the variable "Settings" for. It's not being referenced after you assign it.