Omission: the models and admin used in experiments have changed a bit
from the original post:

from django.db import models

class Base(models.Model):
    name = models.CharField(max_length=10)
    lots_of_text = models.TextField()

    class Meta:
        abstract = True

    def __unicode__(self):
        return self.name

class A(Base):
    a_field = models.CharField(max_length=10)

class B(Base):
    b_field = models.CharField(max_length=10)

class C(Base):
    a = models.ForeignKey(A)
    b = models.ForeignKey(B)
    is_published = models.BooleanField()

---

from django.contrib import admin
from improve_admin.models import A, B, C

class CAdmin(admin.ModelAdmin):
    list_display = ('name', 'a', 'b', 'is_published')
    list_filter = ('a',)

    def queryset(self, request):
        qs = super(CAdmin, self).queryset(request)
        return qs.only('name', 'is_published', 'a', 'b').select_related
().only('a__name')

admin.site.register(A)
admin.site.register(B)
admin.site.register(C, CAdmin)

On Apr 3, 3:03 pm, Mart Somermaa <m...@mrts.pri.ee> wrote:
> and the resulting view is the worst possible: contents of *the large
> text field* are displayed in the changelist instead of __unicode__ --

Correction: __unicode__ still uses C.name, but as #10710 kicks in, the
contents of C.lots_of_text is actually referenced by C.name, so that
is displayed.
--~--~---------~--~----~------------~-------~--~----~
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 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to