Skip to content

Commit bdcb26a

Browse files
committed
v3.1.1
1 parent 969c6b2 commit bdcb26a

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

.ambient-package-update/templates/snippets/content.tpl

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ Add simple interactions to the otherwise static django admin.
4343
from django.urls import path, include
4444

4545
urlpatterns = [
46-
path("admin/", admin.site.urls),
47-
path("dynamic-admin-form/", include("django_dynamic_admin_forms.urls")),
46+
path("admin/", admin.site.urls),
47+
path("dynamic-admin-form/", include("django_dynamic_admin_forms.urls")),
4848
]
4949
```
5050
- In addition to the standard `fields` declaration, specify a list of `dynamic_fields`
@@ -65,23 +65,22 @@ Add simple interactions to the otherwise static django admin.
6565

6666
@admin.register(MyModel)
6767
class MyModelAdmin(DynamicModelAdminMixin, admin.ModelAdmin):
68-
fields = ("name", "city")
69-
dynamic_fields = ("city",)
70-
71-
def get_dynamic_city_field(self, data):
72-
# automatically choose first city that matches first letter of name
73-
name = data.get("name")
74-
if not name:
75-
queryset = City.objects.all()
76-
value = data.get("city")
77-
else:
78-
queryset = City.objects.filter(name__startswith=name[0])
79-
value = queryset.first()
80-
hidden = not queryset.exists()
81-
return queryset, value, hidden
68+
fields = ("name", "city")
69+
dynamic_fields = ("city",)
70+
71+
def get_dynamic_city_field(self, data):
72+
# automatically choose first city that matches first letter of name
73+
name = data.get("name")
74+
if not name:
75+
queryset = City.objects.all()
76+
value = data.get("city")
77+
else:
78+
queryset = City.objects.filter(name__startswith=name[0])
79+
value = queryset.first()
80+
hidden = not queryset.exists()
81+
return queryset, value, hidden
8282
```
8383

84-
8584
## How it works
8685
Whenever a dynamic form changes, an event handler makes a request to a special endpoint, which returns new HTML to swap
8786
into the existing form. This new HTML is directly generated by `django.contrib.admin`, so we only have to set the

.ambient-package-update/templates/snippets/installation.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
- Add the module to `INSTALLED_APPS`:
1212
```python
1313
INSTALLED_APPS = (
14-
'django_dynamic_admin_forms',
15-
'django.contrib.admin',
14+
"django_dynamic_admin_forms",
15+
"django.contrib.admin",
1616
)
1717
```
1818
Ensure that the `dynamic_admin_forms` comes before the
@@ -24,8 +24,8 @@
2424
```python
2525
TEMPLATES = [
2626
{
27-
'BACKEND': 'django.template.backends.django.DjangoTemplates',
28-
'APP_DIRS': True,
27+
"BACKEND": "django.template.backends.django.DjangoTemplates",
28+
"APP_DIRS": True,
2929
},
3030
]
3131
```

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
**3.1.1**
4+
* Black-end documentation code
5+
36
**3.1.0**
47
* Dropped support for Python 3.8
58
* Added multiple ruff linters

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ Add simple interactions to the otherwise static django admin.
9696
return queryset, value, hidden
9797
```
9898

99-
10099
## How it works
101100
Whenever a dynamic form changes, an event handler makes a request to a special endpoint, which returns new HTML to swap
102101
into the existing form. This new HTML is directly generated by `django.contrib.admin`, so we only have to set the
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Add simple dynamic interaction to the otherwise static django admin."""
22

3-
__version__ = "3.1.0"
3+
__version__ = "3.1.1"

0 commit comments

Comments
 (0)