Opened 3 years ago
Closed 3 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)
Change History (2)
by , 3 years ago
| Attachment: | 0eGzOPqZV7.png added |
|---|
comment:1 by , 3 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
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.
Admin View