You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Manage related objects that use GenericForeignKey
53
-
`SBAdminGenericTableInline` and `SBAdminGenericStackedInline` are same as SBAdminTableInline and SBAdminStackedInline, but Generic inlines allow you to manage related objects that use GenericForeignKey.
54
-
55
-
## Fake inlines
56
-
57
-
### SBAdmin Fake Inlines (SBAdminFakeInlineMixin)
58
10
SBAdminFakeInlineMixin is used to create inlines that are dynamically filtered — without needing a real ForeignKey relationship in the database. This is useful when you want to show related data based on some logic (e.g. "products from the same manufacturer") but don’t want to (or can't) define a hard model relation.
59
11
60
12
These inlines are rendered like standard inlines but do not impact database schema.
61
-
####🛠 How it works
13
+
## 🛠 How it works
62
14
- Define inline which extending `SBAdminFakeInlineMixin`
63
15
- For inline, define `filter_fake_inline_identifier_by_parent_instance(self, inline_queryset, parent_instance)`. This controls what queryset will be shown in the inline, based on the parent instance.
64
-
#### 💡 Example
16
+
17
+
## 💡 Example: Products from the same manufacturer
18
+
65
19
This example showcases a fake inline for a Product admin page that lists other products from the same manufacturer.
### Manage related objects that use GenericForeignKey
53
+
`SBAdminGenericTableInline` and `SBAdminGenericStackedInline` are same as SBAdminTableInline and SBAdminStackedInline, but Generic inlines allow you to manage related objects that use GenericForeignKey.
0 commit comments