Hi
I'm new here - in Django and python, more of a Php and wordpress
myself.
anyway - here is my question, hope someone knows the answer.
I have 2 classes - components and customers. every component has a
field that says whos the related customer. like this:
class Component(models.Model):
#
Description = models.CharField(_('Description'),max_length=50,
null=True)
CustomerID = models.ForeignKey(Customer)
#
Works great made the tables, made the links - everything is cool.
Now, i wanted to create a list in the admin and used that:
class ComponentAdmin(admin.ModelAdmin):
list_display = ('ComponentID', 'Description', 'CatologNumber',
'Location', 'stock', 'CustomerID')
So, as one can see I gave Description a field name (which is also
translated) but CustomerId doesn't have one.
in the admin it looks good and there is actually a column that says
CustomerID and is sortable.
The problem is that I want it to say something else, like "Customer
Name"
So, I've tried doing that:
def CustomerName(self):
return self.CustomerID
CustomerName.short_description = _('Customer Name')
and changed ComponentAdmin to:
class ComponentAdmin(admin.ModelAdmin):
list_display = ('ComponentID', 'Description', 'CatologNumber',
'Location', 'stock', 'CustomerName')
Now, the title of the column is indeed Customer Name but the column
is not sortable any more.
So, what can I do? how do i create a title for the column and make it
sortable?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---