Here is my fix for fill_table_cache =======================================================
def fill_table_cache(opts, select, tables, where,old_prefix,cache_tables_seen,processed = {}): """ Helper function that recursively populates the select, tables and where (in place) for select_related queries. """ qn = backend.quote_name if not processed.has_key(opts): processed[opts] = [] processed_fields = processed[opts] for f in opts.fields: if f.rel and not f.null and f not in processed_fields: processed_fields.append(f) db_table = f.rel.to._meta.db_table if db_table not in cache_tables_seen: tables.append(qn(db_table)) else: # The table was already seen, so give it a table alias. new_prefix = '%s%s' % (db_table, len(cache_tables_seen)) tables.append('%s %s' % (qn(db_table), qn(new_prefix))) db_table = new_prefix cache_tables_seen.append(db_table) where.append('%s.%s = %s.%s' % \ (qn(old_prefix), qn(f.column), qn(db_table), qn(f.rel.get_related_field().column))) select.extend(['%s.%s' % (qn(db_table), qn(f2.column)) for f2 in f.rel.to._meta.fields]) fill_table_cache(f.rel.to._meta, select, tables, where, db_table, cache_tables_seen, processed) ============================================================= And here is models for test ============================================================= class Domain(models.Model): name = models.CharField(unique=True, maxlength=96) parent = models.ForeignKey('self', db_column='parent') ip = models.IPAddressField() def __str__(self): cur = self path = "/" + cur.name while(cur != cur.parent): cur = cur.parent path = "/" + cur.name + path return path def path(self): return self.__str__() class Admin: list_display = ('path',) search_fields = ['name'] ordering = ('name',) class Choice(models.Model): choice = models.CharField(maxlength=200, core=True) votes = models.IntegerField(core=True) cat = models.ForeignKey(Domain) def __str__(self): return self.choice class Admin: list_display = ('choice','votes','cat') ================================================================ --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---