All,
I have the following in my views.py
def getgradeform(request):
id1=request.user.get_pf().id
sc=Sc.objects.filter(id=id1)
logging.debug(sc)
logging.debug("++++")
dict={}
dict.update({'sc': sc})
return render_to_response('content/add.html',dict)
Logging.debug gives an output as [<sc: Robert>]
My question is that how do i display Robert in the template .
I have tried the following in the template:<input type ="text" value={{sc}}/> //This gives me the dictionary itself
<input type ="text" value={{dict.sc}}/> //This also doesnt work.
Thanks……
If you want any value in a dictionary, you have to do it on the way
(On python you’ll write it as dict[‘key’])
So, to present the value stored with key ‘name’
Anyway, I think this is not you’re case. I think you’re not seeing a dictionary, but an object defined from models (as is a entry on the database).
You’re storing in
dict(don’t call that value asdict, you’re masking a keyword) a key ‘sc’ with value variablesc, which is returned from a model. I’m having to guess, because I don’t know how this model is. Maybe ‘Robert’ is stored in the attributename,idor something similar?You need to show then the proper attribute, something like