Opened 2 years ago

Closed 2 years ago

#33869 closed Uncategorized (invalid)

Self Reference Inlines is not working form me

Reported by: Ahmed F. Owned by: nobody
Component: Uncategorized Version: 4.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I created a simple Self Reference model for a family tree and when added inlines to the model it is not working , code below:

models.py

class Person(models.Model):
    pname = models.CharField("Name",max_length=100)
    father = models.ForeignKey("familytree.Person", on_delete=models.CASCADE,null=True, blank=True, editable=False)
    def __str__(self):
        return self.pname

admin.py

class PersonInline(admin.TabularInline):
    model: Person
    fields = ['pname',]
    extra: 3

class PersonAdmin(admin.ModelAdmin):
    fieldsets = [
    (None, {'fields': ['pname']}),
    ]
    inlines: (PersonInline)

admin.site.register(Person, PersonAdmin)

Attachments (1)

0eGzOPqZV7.png (41.6 KB ) - added by Ahmed F. 2 years ago.
Admin View

Download all attachments as: .zip

Change History (2)

by Ahmed F., 2 years ago

Attachment: 0eGzOPqZV7.png added

Admin View

comment:1 by Mariusz Felisiak, 2 years ago

Resolution: invalid
Status: newclosed

It looks like you forgot a comma:

inlines: (PersonInline,)

For the future, please don't use Trac as a support channel. Closing per TicketClosingReasons/UseSupportChannels.

Note: See TracTickets for help on using tickets.
Back to Top