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
Copy file name to clipboardExpand all lines: docs/inlines/options.md
+30-3Lines changed: 30 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,17 @@ description: Customize Django Unfold inline options including title customizatio
6
6
7
7
# Available options for Unfold inlines
8
8
9
-
By default, each inline row's title is derived from the model's `__str__` implementation. However, Unfold provides the ability to customize this title specifically for inlines by implementing a `get_inline_title` method on the model, which can return a custom title that will only be used in inline contexts.
9
+
## Custom inline title
10
+
11
+
By default, each inline row's title is derived from the model's `__str__` implementation. However, Unfold provides the ability to customize this title specifically for inlines by implementing a `get_inline_title` method on the model. This method can return a custom title that will only be used in inline contexts, allowing for more descriptive and context-specific labels.
10
12
11
13
```python
12
14
from django.contrib.auth.models import User
13
15
from unfold.admin import TabularInline
14
16
15
17
16
18
classUser(models.Model):
17
-
#fiels, meta ...
19
+
#fields, meta ...
18
20
19
21
defget_inline_title(self):
20
22
return"Custom title"
@@ -26,7 +28,7 @@ class MyInline(TabularInline):
26
28
27
29
## Hide title row
28
30
29
-
You can hide the title row for both `StackedInline` and `TabularInline` by setting the `hide_title` attribute to `True`. Note that for `StackedInline`, the delete permission (`can_delete`) must be disabled to hide the title row since the delete checkbox is contained within it.
31
+
You can hide the title row for both `StackedInline` and `TabularInline` by setting the `hide_title` attribute to `True`. This feature is particularly useful when you want to create a more compact and streamlined interface. Please note that for `StackedInline`, the delete permission (`can_delete`) must be disabled to hide the title row, as the delete checkbox is contained within it.
30
32
31
33
```python
32
34
# admin.py
@@ -39,3 +41,28 @@ class MyInline(TabularInline):
39
41
model = User
40
42
hide_title =True
41
43
```
44
+
45
+
## Collapsible StackedInline
46
+
47
+
Unfold enhances the `StackedInline` functionality by introducing a collapsible mode. When enabled, this feature allows you to display multiple records in a space-efficient manner by defaulting to a collapsed state. This is particularly useful when dealing with forms that contain numerous inline entries, as it helps maintain a clean and organized interface.
48
+
49
+
Key features of collapsible StackedInlines:
50
+
- Records are collapsed by default, saving vertical space
51
+
- Users can expand individual records as needed
52
+
- Records containing validation errors automatically expand to highlight the issues
53
+
- The collapsed state is preserved during form submission
54
+
- Each record can be independently expanded or collapsed
55
+
56
+
To implement this feature, simply set the `collapsible` attribute to `True` in your StackedInline class:
description: Implement paginated inlines in Django Unfold to efficiently manage large datasets by breaking down inline records into manageable pages, with customizable per-page settings and support for multiple paginated inlines.
5
+
---
6
+
7
+
Pagination on inlines can be enabled by providing the `per_page` property in the inline class. This feature is particularly useful when dealing with models that have a large number of related objects, as it helps improve page load times and provides a better user experience by breaking down the data into manageable chunks. The `per_page` property accepts an integer value that determines how many inline records will be displayed on each page.
It is possible to define multiple paginated inlines on the same page without any conflicts. This flexibility allows administrators to work with complex models that have multiple relationships, each potentially containing numerous records. Django Unfold handles the pagination state independently for each inline, ensuring that navigating through one inline's pages doesn't affect the pagination state of other inlines on the same admin page.
12
+
13
+
Each inline has its own unique query parameter in the URL to maintain its pagination state. This implementation ensures that when users navigate between pages of different inlines, the system can track and maintain the current page for each inline separately. The unique query parameters are automatically generated and managed by Django Unfold, so developers don't need to worry about potential conflicts or parameter naming conventions.
14
+
15
+
AJAX pagination is not currently supported for inlines. This means that when users click on pagination links, the entire admin page will reload to display the new set of records. While this approach may not be as seamless as AJAX-based pagination, it ensures compatibility with Django's existing admin infrastructure and maintains the reliability of the admin interface functionality.
16
+
17
+
If inline records fit on only one page, no pagination controls will be displayed to keep the interface clean and uncluttered. Django Unfold automatically detects when the total number of records is less than or equal to the specified `per_page` value and hides the pagination controls accordingly. This intelligent behavior prevents unnecessary UI elements from appearing when they serve no functional purpose.
18
+
19
+
```python
20
+
from unfold.admin import StackedInline, TabularInline, GenericStackedInline, GenericTabularInline
21
+
from unfold.contrib.inlines.admin import NonrelatedStackedInline, NonrelatedTabularInline
0 commit comments