Skip to content

Commit

Permalink
v3.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
GitRon committed Jun 21, 2024
1 parent b3fe11f commit 191d8ab
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 40 deletions.
5 changes: 1 addition & 4 deletions .ambient-package-update/templates/snippets/content.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ Add simple interactions to the otherwise static django admin.
- Add the module to `INSTALLED_APPS`:
```python
INSTALLED_APPS = (
...,
'django_dynamic_admin_forms',
'django.contrib.admin'
...
'django.contrib.admin',
)
```
Ensure that the `dynamic_admin_forms` comes before the
Expand All @@ -32,7 +30,6 @@ Add simple interactions to the otherwise static django admin.
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
...
},
]
```
Expand Down
5 changes: 1 addition & 4 deletions .ambient-package-update/templates/snippets/installation.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
- Add the module to `INSTALLED_APPS`:
```python
INSTALLED_APPS = (
...,
'django_dynamic_admin_forms',
'django.contrib.admin'
...
'django.contrib.admin',
)
```
Ensure that the `dynamic_admin_forms` comes before the
Expand All @@ -28,7 +26,6 @@
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
...
},
]
```
Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ repos:
# Run the Ruff formatter.
- id: ruff-format

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies:
- black==24.4.2
files: '(?:README\.md|docs\/.*\.(?:md|rst))'

- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
hooks:
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

**3.0.4**
* Linted docs with `blacken-docs` via `ambient-package-update`

**3.0.3**
* Restructured Readme content

Expand Down
54 changes: 24 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ Add simple interactions to the otherwise static django admin.
- Add the module to `INSTALLED_APPS`:
```python
INSTALLED_APPS = (
...,
'django_dynamic_admin_forms',
'django.contrib.admin'
...
"django_dynamic_admin_forms",
"django.contrib.admin",
)
```
Ensure that the `dynamic_admin_forms` comes before the
Expand All @@ -45,9 +43,8 @@ Add simple interactions to the otherwise static django admin.
```python
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
...
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
},
]
```
Expand All @@ -61,8 +58,8 @@ Add simple interactions to the otherwise static django admin.
from django.urls import path, include

urlpatterns = [
path("admin/", admin.site.urls),
path("dynamic-admin-form/", include("django_dynamic_admin_forms.urls")),
path("admin/", admin.site.urls),
path("dynamic-admin-form/", include("django_dynamic_admin_forms.urls")),
]
```
- In addition to the standard `fields` declaration, specify a list of `dynamic_fields`
Expand All @@ -83,20 +80,20 @@ Add simple interactions to the otherwise static django admin.

@admin.register(MyModel)
class MyModelAdmin(DynamicModelAdminMixin, admin.ModelAdmin):
fields = ("name", "city")
dynamic_fields = ("city",)

def get_dynamic_city_field(self, data):
# automatically choose first city that matches first letter of name
name = data.get("name")
if not name:
queryset = City.objects.all()
value = data.get("city")
else:
queryset = City.objects.filter(name__startswith=name[0])
value = queryset.first()
hidden = not queryset.exists()
return queryset, value, hidden
fields = ("name", "city")
dynamic_fields = ("city",)

def get_dynamic_city_field(self, data):
# automatically choose first city that matches first letter of name
name = data.get("name")
if not name:
queryset = City.objects.all()
value = data.get("city")
else:
queryset = City.objects.filter(name__startswith=name[0])
value = queryset.first()
hidden = not queryset.exists()
return queryset, value, hidden
```


Expand Down Expand Up @@ -155,10 +152,8 @@ $ yarn cypress # or npm run cypress
- Add the module to `INSTALLED_APPS`:
```python
INSTALLED_APPS = (
...,
'django_dynamic_admin_forms',
'django.contrib.admin'
...
"django_dynamic_admin_forms",
"django.contrib.admin",
)
```
Ensure that the `dynamic_admin_forms` comes before the
Expand All @@ -170,9 +165,8 @@ $ yarn cypress # or npm run cypress
```python
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
...
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
},
]
```
Expand Down
2 changes: 1 addition & 1 deletion django_dynamic_admin_forms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Add simple dynamic interaction to the otherwise static django admin."""

__version__ = "3.0.3"
__version__ = "3.0.4"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dev = [
'm2r2==0.3.3.post2',
'mistune<2.0.0',
'flit~=3.9',
'ambient-package-update~=24.6.3',
'ambient-package-update~=24.6.4',
'unittest-parametrize~=1.4',
]

Expand Down

0 comments on commit 191d8ab

Please sign in to comment.