Yes, I actually had an error elsewhere apologies. I understand objects fine, BTW but am new to Django (beyond the tutorials).
It was odd to me that the error was happening it seemed like i should have had access to the data.All set now. On Jul 22, 4:01 pm, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Jul 22, 8:54 pm, rpupkin77 <pthompson2...@gmail.com> wrote: > > > > > Hi, > > > this is probably a really basic question, but i can't find the answer > > anywhere. > > > I need to get data from a model and use it in the view (views.py), > > before I pass it to the template. However, the result I get back (when > > i examine the local vars) has only the value returned by the __unicode > > function, in this instance, the "title" column. > > > I need the title to continue to be what is returned by unicode but i > > need access to a different field in that model and pass it to a third > > party api. > > > essentially my code would looks like this: > > > from models import Video > > > def get_video_ids: > > vids = Video.objects.all() > > > for vids in vid > > do stuff > > > the vids variable contains a list like this: [Video: vid title one, > > Video: vid title two] > > > I essentially need the id. > > > I have tried different ways of extracting, but they fail. > > > Thanks. > > You don't just get the unicode, you get the whole object. If you just > type 'vid' into the console, of course you'll just see the unicode > representation (actually it's the value of __repr__, which in turn > calls __unicode__) but the whole object is there. You access other > attributes like you would any other object - vid.id, vid.field1, etc. > > It sounds like you don't really understand objects in Python, or maybe > objects at all. I recommend you read a basic beginner's guide to > programming in Python - there's a list > here:http://wiki.python.org/moin/BeginnersGuide/NonProgrammers > I haven't read any of them (I learned from Dive Into Python, which is > aimed at people who already know programming from other languages) but > I've heard "How to think like a computer scientist" is good. > -- > DR. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---