Hi All,
My Problem: I'm adapting the generated models from inspectdb in order to
use a legacy application with django. The application database schema
has intermediary tables in it - I'd want to use the nice
"filter_horizontal" instead of inlines. Inlines do work, so the
intermediary table lookup works fine - but with filter_horizontal the
admin panel just doesnt show up the relations - no warnings nor errors.
Thanks for having a look at it,
Greetings from Luxemburg,
Jean
#models.py
class Person(models.Model):
id = models.AutoField(primary_key=True, db_column='PersonId')
name = models.CharField(max_length=300, db_column='PersonName')
groups = models.ManyToManyField('Group', through='Membership')
class Group(models.Model):
id = models.AutoField(primary_key=True, db_column='GroupId')
name = models.CharField(max_length=300, db_column='GroupName')
members = models.ManyToManyField('Person', through='Membership')
class Membership(models.Model):
id = models.AutoField(primary_key=True, db_column='Id')
person = models.ForeignKey(Person, db_column='PersonId')
group = models.ForeignKey(Group, db_column='GroupId')
#admin.py
class Membership_inline(admin.TabularInline):
model = Membership
extra = 1
class PersonAdmin(admin.ModelAdmin):
search_fields = ['name']
#inlines = [ Membership_inline ]
filter_horizontal = ('groups',)
class GroupAdmin(admin.ModelAdmin):
search_fields = ['name']
#inlines = [ Membership_inline ]
filter_horizontal = ('persons',)
admin.site.register(Person, PersonAdmin)
admin.site.register(Group, GroupAdmin)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---