A
A
Alexander2017-06-26 12:09:16
Django
Alexander, 2017-06-26 12:09:16

How to make StackedInline look for a ForeignKey other than itself?

There are two tables: table, table1
models.py:

class Table(models.Model):
    table1 = models.ForeignKey(Table1)

class Table1(models.Model):
    text = models.TextField(verbose_name='текст')

admin.py:
class Table1Inline(admin.StackedInline):
    model = Table1


class TableAdmin(admin.ModelAdmin):
    pass
    inlines = [
        Table1Inline,
    ]

django complains: 'Table1' has no ForeignKey to 'Table'. How to make StackedInline look not for the key itself, but for the one who stacks it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2017-06-26
@deliro

I'm just hinting transparently
c4ddf1caeb104fd288075090dba5c2fb.jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question