Я относительно новичок в Django, и в настоящее время я использую встроенное приложение администратора. Я получаю следующую ошибку («пожалуйста, исправьте ошибки ниже») всякий раз, когда я пытаюсь добавить / сохранить встроенную дочернюю группу и когда я делаю простое редактирование для Родителя. Если не включить inline, добавление, редактирование и удаление работают нормально. Я не слишком уверен, как решить эту проблему. Я пробовал несколько вещей, основанных на том, что доступно через поиск в Google, но до сих пор не пришли к решению.

вот фрагмент моей модели:

class Group(models.Model):  # Parent
    groupid = models.CharField('Group ID',db_column='groupId', primary_key=True, auto_created=True, default=uuid.uuid4, max_length=36)  # Field name made lowercase.
    groupabbr = models.CharField('Group Abbr',db_column='groupAbbr', max_length=30)  # Field name made lowercase.
    groupname = models.CharField('Group Name',db_column='groupName', max_length=100)  # Field name made lowercase.
    groupemail = models.EmailField('Group Email',db_column='groupEmail', max_length=200, blank=True, null=True)  # Field name made lowercase.
    # description = models.TextField(db_column='description', max_length=255, blank=True, null=True)
    description = models.CharField(db_column='description', max_length=255, blank=True, null=True)
    fkpripocpersonid = models.ForeignKey(Person,db_column='fkPriPocPersonId', related_name='priPocForGroups', on_delete=models.SET_NULL, max_length=36, blank=True, null=True, verbose_name='Primary POC')  # Field name made lowercase.
    fksecpocpersonid = models.ForeignKey(Person,db_column='fkSecPocPersonId', related_name='secPocForGroups', on_delete=models.SET_NULL, max_length=36, blank=True, null=True, verbose_name='Secondary POC')  # Field name made lowercase.
    primaryfieldtitle = models.CharField('Primary Field Title',db_column='primaryFieldTitle', max_length=100, blank=True, null=True)  # Field name made lowercase.
    primaryfieldcontent = models.TextField('Primary Field Content',db_column='primaryFieldContent', blank=True, null=True)  # Field name made lowercase.
    secondaryfieldtitle = models.CharField('Secondary Field Title',db_column='secondaryFieldTitle', max_length=100, blank=True, null=True)  # Field name made lowercase.
    secondaryfieldcontent = models.TextField('Secondary Field Content',db_column='secondaryFieldContent', blank=True, null=True)  # Field name made lowercase.
    createddate = models.DateTimeField('Date Created',db_column='createdDate', default=datetime.now())  # Field name made lowercase.
    createdby = models.ForeignKey(Person, db_column='createdBy', related_name='createdGroups', on_delete=models.SET_NULL, max_length=36,  null=True, verbose_name='Created By')  # Field name made lowercase.
    archiveddate = models.DateTimeField('Date Archived',db_column='archivedDate',
                                        default=datetime.now(), blank=True, null=True)  # Field name made lowercase.
    archivedby = models.ForeignKey(Person, db_column='archivedBy', related_name='archivedGroups', on_delete=models.SET_NULL, max_length=36, blank=True, null=True, verbose_name='Archived By')  # Field name made lowercase.
    fkparentgroupid = models.ForeignKey('self', db_column='fkParentGroupId', related_name='Parents',
                                        on_delete=models.CASCADE, null=True, verbose_name='Parent Group',
                                        max_length=36, blank=True)

    def __str__(self):  # this object's representation used throughout Django
        return self.groupabbr + ' - ' + self.groupname


    class Meta:
        managed = False
        db_table = 'tbl_group'
        ordering = ('groupname',)

Вот фрагмент моего Admin.py:

class GroupInline(admin.TabularInline):
    model = Group
    classes = ['collapse']
    exclude = ['groupemail','primaryfieldtitle', 'primaryfieldcontent',
               'archiveddate', 'archivedby', 'createddate', 'createdby', 'secondaryfieldtitle',
               'secondaryfieldcontent',]
    """list_display = ('groupid', 'groupabbr','groupname', 'description', 'fkpripocpersonid', 'fksecpocpersonid',
                    'createddate', 'createdby') """
    list_editable = ('groupid', 'groupabbr','groupname', 'description', 'fkpripocpersonid', 'fksecpocpersonid',
                    'createddate', 'createdby')
    extra = 0



class GroupExistingInline(admin.TabularInline):
    model = Group
    classes = ['collapse']
    exclude = ['groupemail','primaryfieldtitle', 'primaryfieldcontent',
               'archiveddate', 'archivedby', 'createddate', 'createdby', 'secondaryfieldtitle',
               'secondaryfieldcontent', 'groupid',]
    readonly_fields = ('groupabbr','groupname', 'description', 'fkpripocpersonid', 'fksecpocpersonid',
                       'createddate', 'createdby')
    extra = 0

    def has_add_permission(self, request):
        return False


class GroupAdmin(admin.ModelAdmin, ExportCsvMixin):
    list_display = ('groupabbr','groupname', 'fkparentgroupid', 'fkpripocpersonid', 'fksecpocpersonid')
    list_filter = ('groupname',)
    actions = ["export_as_csv"]
    inlines = [GroupExistingInline, GroupInline, ]
    fieldsets = [
        (None, {'fields': ('fkparentgroupid', ('groupname', 'groupabbr'),
                           'description', 'groupemail', ('fkpripocpersonid', 'fksecpocpersonid',),  ('createddate',
                           'createdby'),)}),
        ('Primary Content', {
            'classes': ('collapse',),  # collapse, wide, extrapretty
            'fields': ['primaryfieldtitle', 'primaryfieldcontent', ],
        }),
        ('Secondary Content', {
            'classes': ('collapse',),  # collapse, wide, extrapretty
            'fields': ['secondaryfieldtitle', 'secondaryfieldcontent', ],
        }),

    ]



    def __init__(self, model, admin_site):
        self.form.admin_site = admin_site
        super(GroupAdmin, self).__init__(model, admin_site)


    def get_actions(self, request):
        actions = super().get_actions(request)
        if 'delete_selected' in actions:
            del actions['delete_selected']
        return actions


admin.site.register(Group, GroupAdmin)

0
KenNotAnthony