How to retrieve objects from database? How to filter objects?
Aug 022009

__unicode__

is for displaying objects.

———–

For example,

>>>p = Card.objects.create(name=’Hot Pot’, city=’San Diego’)

>>>card_list = Card.objects.all()

>>>card_list

[<Card: Card object>]

without __unicode__, you will see just “Card object”

if you define __unicode__

def __unicode__(self):

return self.name

then, you will see

[<Card: Hot Pot>]

Posted by weboom at 5:22 am Tagged with: , ,

Leave a Reply

(required)

(required)

Switch to our mobile site
Top Footer