[Answer]-Django Add ManyToMany Relationship to Admin User Form

1👍

In django this feature names related_name or "back reference" in SQLAlchemy. As you can see in docs:

If a model has a ForeignKey, instances of the foreign-key model will have access to a Manager that returns all instances of the first model. By default, this Manager is named FOO_set, where FOO is the source model name, lowercased.

So, in your case you should use facility_set or redefine related_name on users
ManyToMany field in Facility model.

BTW, @schillingt: suggestion to use InlineModelAdmin much more easy and elegant than anything else.

Leave a comment