django models - need to return an attribute of an object from an object in a list -


ive got following code

def get_photograph(self):     pdb.set_trace()     photograph = photograph.objects.filter(project=self)[:1]     filename = photograph["photograph"]     return filename 

which returns object in list thus

[<photograph: b>] 

its returning attribute want, b filename of actual image minus extension. why doesn't line

    filename = photograph["photograph"] 

return actual filename. reading through dive python book , can't work out why doesn't work. unless not list of objects, in case i'm stumped.

edit simple solution one...

def get_photograph(self):     photograph = photograph.objects.filter(project=self)[:1]     return photographs[0].filename 

answer came me after taking break, why isn't simple.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -