I\'ve read about the can_add_related feature here: https://code.djangoproject.com/ticket/9071
I tried using it this way:
def get_form(self, request,
Alternative approach, with changing widget options *before* the form is instantiated:
class MyAdmin(django.contrib.admin.ModelAdmin):
def formfield_for_dbfield(self, *args, **kwargs):
formfield = super().formfield_for_dbfield(*args, **kwargs)
if hasattr(formfield, "widget"):
formfield.widget.can_add_related = False
formfield.widget.can_delete_related = False
formfield.widget.can_change_related = False
else:
pass # this relation doesn't have an admin page to add/delete/change
return formfield