Re: AW: __str__, __unicode__ representation of model fields

2008-11-04 Thread Donn
On Monday, 03 November 2008 10:50:34 Bülent Aldemir wrote: > I want to have a nice representation for the other MyModel() fields. Must I > define for each field a method to accomplish my task? Seems the best way. There's only one 'repr' for any object and if you want specific ones then either mak

AW: __str__, __unicode__ representation of model fields

2008-11-03 Thread Bülent Aldemir
Betreff: Re: __str__, __unicode__ representation of model fields To get an integer to print with leading 0s print '%0d' % my_model.myinteger To get an integer to print with 10 digits, filled with leading 0s print '%0.10d' % my_model.myinteger If you wanted this to be the default value

Re: __str__, __unicode__ representation of model fields

2008-11-02 Thread JoeJ
To get an integer to print with leading 0s print '%0d' % my_model.myinteger To get an integer to print with 10 digits, filled with leading 0s print '%0.10d' % my_model.myinteger If you wanted this to be the default value shown for the model def __unicode__(self): return u'%0.10d' % self.myinteg

__str__, __unicode__ representation of model fields

2008-11-02 Thread Bülent Aldemir
Hi, given class MyModel(models.Model): name = models.CharField(max_length=150) myinteger = models.IntegerField() ^ def __unicode__(self): return u"Here is my: %s" % (self.name) one has to give a __unicode__ method to get a nice string representation of MyModel() I need