On 8/23/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> So my question is, is there a patch coming soon where we will be able
> to include related fields of models in the admin columns as well as
> search sort and filter on them? If not, is it a good idea for me to
> start on functionality like this with the outstanding tickets
> currently.

Hi Trey,

This is already possible. You asked two questions, so I'll answer both
of them --

To include related fields of models in change list columns, just
include the foreign key in the "list_display" option:

    class Person(models.Model):
        name = models.CharField(max_length=100)
        hometown = models.ForeignKey(City)

        class Admin:
            list_display = ('name', 'hometown')

In this case, Django will follow the foreign-key relationship and
display the value of the hometown's __unicode__() for each row.

Note that we intentionally do not support many-to-many fields in
list_display, because that would require a separate query for each
row. But if you really want to do that, you can create a custom
method. See the docs here:

http://www.djangoproject.com/documentation/model-api/#list-display

Regarding your second question, an admin-site feature that is
relatively unknown is the fact that you can pass any valid filter()
argument to the change list's query string. For example:

    http://example.com/admin/myapp/poll/?id__lt=3

There is no user interface for this, but that would be nice. If you're
willing to contribute (which it sounds like you are), that'd be the
area I'd suggest focusing on.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to