According to Django documentation it's possible. filter_horizontal is 
supposed to extend to InlineModelAdmin. But I've been at a pretty bad 
stopping point of not knowing the syntax for how to get this to work, and 
not being able to even find an example of someone doing this.

I have a model called Statement. Statement has an m2m relationships with 
another model called Keywords. In other words, each statement has a set of 
keywords. and I'm trying to change its change/add page by allowing one to 
be able to modify the keywords associated with a Statement.

However, when I design admin.py like this and run python manage.py 
makemigrations, I get the error at the bottom. statements is a m2m field 
within Keywords, so I'm not really sure what to do at this point. I've been 
trying a lot of variants but nothing's really working and I don't 
understand where to begin.


class KeywordInline(admin.TabularInline):
    model = Keyword.statement.through
    filter_horizontal = ('statement',)

class KeywordAdmin(admin.ModelAdmin):
    inlines = [KeywordInline,]

class StatementAdmin(admin.ModelAdmin):
    inlines = [ KeywordInline,]

SystemCheckError: System check identified some issues:

ERRORS:
<class 'gtr_site.admin.KeywordInline'>: (admin.E020) The value of 
'filter_horizontal[0]' must be a many-to-many field.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3ea032b0-0b39-4235-9ba9-9a371421c38d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to