2009/9/2 Mike Dewhirst <mi...@dewhirst.com.au>:
>
> Joakim Hove wrote:
>> Hello,
>>
>> I have a (simplified) model like this
>>
>> class Customer(models.Model):
>>      name  =   models.CharField(max_length = 100)
>>      date    =   models.DateTimeField()
>>      email  =   models.EmailField()
>>
>>
>> When showing this in the (100 % default) admin view I get up nice
>> entry boxes for the fields 'name', 'date' and 'email'. In addition I
>> would very much like to display the 'id' field which django has
>> automatically added (preferably as readonly). Any tips on how to
>> achieve this?
>
>     @property
>     def id_field(self):
>         return self.pk
>
>     def __unicode__(self):
>         return u'%s : %s' % (self.id_field, self.name)
>

Why not just

def __unicode__(self):
         return u'%s : %s' % (self.id, self.name)

On the other hand it you can use also list_display, but requires to
create an admin.py file.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to