[Answered ]-Organizations.OrganizationGroups has no ForeignKey to 'auth.User'

1👍

I have solved the issue, it was caused by the way I was generating the OrganizationGroups inline using get_inlines in GroupAdmin (which is an override to the default GroupAdmin). Before I was using super().get_inlines(request, obj) and when I went to another module, the module was trying to recreate the OrganizationGroups inline, and the module did not have the relationship to OrganizationGroups (because it did not have to), and that is when it broke. Now I am generating the inline creating a completely new list without using super().get_inlines(request, obj) and apparently that solved the issue.

OrganizationInline:

class OrganizationInline(StackedInline):
    model = Organization.groups.through
    autocomplete_fields = ('organization')
    extra = 0
    min_num = 0
    max_num = 1
    verbose_name = _('organización')
    verbose_name_plural = _('organizaciones')

Previous get_inlines code:

def get_inlines(self, request, obj):
        inlines = super().get_inlines(request, obj)
        if request.user.is_superuser:
            inlines.clear()
            inlines.append(OrganizationInline)
        return inlines

New get_inlines code:

def get_inlines(self, request: HttpRequest, obj):
        if request.user.is_superuser:
            return [OrganizationInline]
        return []

Leave a comment