django-dynamic-admin-forms 3.0.2__tar.gz → 3.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_dynamic_admin_forms-3.0.4/.ambient-package-update/metadata.py +45 -0
- django_dynamic_admin_forms-3.0.2/.ambient-package-update/metadata.py → django_dynamic_admin_forms-3.0.4/.ambient-package-update/templates/snippets/content.tpl +125 -207
- django_dynamic_admin_forms-3.0.4/.ambient-package-update/templates/snippets/installation.tpl +33 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/.pre-commit-config.yaml +8 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/CHANGES.md +6 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/PKG-INFO +44 -37
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/README.md +42 -35
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/django_dynamic_admin_forms/__init__.py +1 -1
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/pyproject.toml +1 -1
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/.coveragerc +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/.editorconfig +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/.github/workflows/ci.yml +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/.gitignore +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/.python-version +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/.readthedocs.yaml +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/LICENSE.md +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/MANIFEST.in +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/django_dynamic_admin_forms/admin.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/django_dynamic_admin_forms/apps.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/django_dynamic_admin_forms/static/js/dynamic_admin.js +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/django_dynamic_admin_forms/templates/admin/change_form.html +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/django_dynamic_admin_forms/urls.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/docs/Makefile +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/docs/conf.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/docs/demo.gif +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/docs/features/changelog.rst +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/docs/index.rst +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/docs/make.bat +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/e2e/cypress/integration/dynamic-select.spec.js +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/e2e/cypress/plugins/index.js +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/e2e/cypress/support/commands.js +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/e2e/cypress/support/index.js +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/e2e/cypress/support/paths.js +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/e2e/cypress.json +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/e2e/package.json +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/e2e/yarn.lock +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/fixtures/fixtures-dev.json +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/manage.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/scripts/unix/install_requirements.sh +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/scripts/unix/publish_to_pypi.sh +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/scripts/windows/install_requirements.ps1 +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/scripts/windows/publish_to_pypi.ps1 +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/settings.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/setup.cfg +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/testapp/__init__.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/testapp/admin.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/testapp/apps.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/testapp/migrations/0001_initial.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/testapp/migrations/0002_extend_example.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/testapp/migrations/0003_example_file_field.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/testapp/migrations/__init__.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/testapp/models.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/testapp/urls.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/tests/__init__.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/tests/test_admin_generic.py +0 -0
- {django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/tests/test_admin_unit.py +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from ambient_package_update.metadata.author import PackageAuthor
|
|
2
|
+
from ambient_package_update.metadata.constants import (
|
|
3
|
+
DEV_DEPENDENCIES,
|
|
4
|
+
SUPPORTED_DJANGO_VERSIONS,
|
|
5
|
+
SUPPORTED_PYTHON_VERSIONS,
|
|
6
|
+
)
|
|
7
|
+
from ambient_package_update.metadata.maintainer import PackageMaintainer
|
|
8
|
+
from ambient_package_update.metadata.package import PackageMetadata
|
|
9
|
+
from ambient_package_update.metadata.readme import ReadmeContent
|
|
10
|
+
|
|
11
|
+
METADATA = PackageMetadata(
|
|
12
|
+
package_name="django_dynamic_admin_forms",
|
|
13
|
+
module_name="django_dynamic_admin_forms",
|
|
14
|
+
github_package_name="django_dynamic_admin",
|
|
15
|
+
company="Ambient Innovation: GmbH",
|
|
16
|
+
authors=[
|
|
17
|
+
PackageAuthor(
|
|
18
|
+
name="Ambient Digital",
|
|
19
|
+
email="hello@ambient.digital",
|
|
20
|
+
),
|
|
21
|
+
PackageAuthor(
|
|
22
|
+
name="Fabian Binz",
|
|
23
|
+
email="fabian.binz@ambient.digital",
|
|
24
|
+
),
|
|
25
|
+
],
|
|
26
|
+
maintainer=PackageMaintainer(name="Ambient Digital", url="https://ambient.digital/", email="hello@ambient.digital"),
|
|
27
|
+
license_year=2022,
|
|
28
|
+
development_status="5 - Production/Stable",
|
|
29
|
+
has_migrations=False,
|
|
30
|
+
readme_content=ReadmeContent(
|
|
31
|
+
tagline="Add simple interactions to the otherwise static django admin.",
|
|
32
|
+
),
|
|
33
|
+
supported_django_versions=SUPPORTED_DJANGO_VERSIONS,
|
|
34
|
+
supported_python_versions=SUPPORTED_PYTHON_VERSIONS,
|
|
35
|
+
dependencies=[
|
|
36
|
+
"django >=3.2",
|
|
37
|
+
],
|
|
38
|
+
optional_dependencies={
|
|
39
|
+
"dev": [
|
|
40
|
+
*DEV_DEPENDENCIES,
|
|
41
|
+
"unittest-parametrize~=1.4",
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
ruff_ignore_list=[],
|
|
45
|
+
)
|
|
@@ -1,207 +1,125 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
##
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
- does not validate that the selected value is really part of the original queryset
|
|
127
|
-
- if anybody can modify your DOM, they could potentially inject invalid values
|
|
128
|
-
- you have to write `Model.clean()` methods to guard against that
|
|
129
|
-
- only tested with Django 3.2
|
|
130
|
-
|
|
131
|
-
## Development
|
|
132
|
-
|
|
133
|
-
For local development, create a virtual environment
|
|
134
|
-
in the `testproj` folder:
|
|
135
|
-
```shell
|
|
136
|
-
$ cd testproj
|
|
137
|
-
$ python3 -m venv .venv
|
|
138
|
-
$ source .venv/bin/activate
|
|
139
|
-
$ cd ..
|
|
140
|
-
$ flit install --symlink
|
|
141
|
-
```
|
|
142
|
-
Now the package should be available in your virtual environment
|
|
143
|
-
and any changes should be directly visible.
|
|
144
|
-
|
|
145
|
-
Alternatively, copy the directory `dynamic_admin_forms`
|
|
146
|
-
into any normal django project, so that the python interpreter
|
|
147
|
-
finds the local version instead of the installed (old) version.
|
|
148
|
-
|
|
149
|
-
## Running E2E tests
|
|
150
|
-
|
|
151
|
-
To run end-to-end tests locally:
|
|
152
|
-
```shell
|
|
153
|
-
$ cd testproj
|
|
154
|
-
$ python manage.py runserver 0.0.0.0:8000 & # start server
|
|
155
|
-
$ python manage.py loaddata fixtures/fixtures-dev.json
|
|
156
|
-
$ cd ../e2e
|
|
157
|
-
$ yarn install # or npm install (only needed first time)
|
|
158
|
-
$ yarn cypress # or npm run cypress
|
|
159
|
-
```
|
|
160
|
-
""",
|
|
161
|
-
custom_installation="""
|
|
162
|
-
- Install the package via pip:
|
|
163
|
-
|
|
164
|
-
```pip install django-dynamic-admin-forms```
|
|
165
|
-
|
|
166
|
-
or via pipenv:
|
|
167
|
-
|
|
168
|
-
```pipenv install django-dynamic-admin-forms```
|
|
169
|
-
- Add the module to `INSTALLED_APPS`:
|
|
170
|
-
```python
|
|
171
|
-
INSTALLED_APPS = (
|
|
172
|
-
...,
|
|
173
|
-
'django_dynamic_admin_forms',
|
|
174
|
-
'django.contrib.admin'
|
|
175
|
-
...
|
|
176
|
-
)
|
|
177
|
-
```
|
|
178
|
-
Ensure that the `dynamic_admin_forms` comes before the
|
|
179
|
-
default `django.contrib.admin` in the list of installed apps,
|
|
180
|
-
because otherwise the templates, which are overwritten by `dynamic_admin_forms`
|
|
181
|
-
won't be found.
|
|
182
|
-
- Ensure that the `dynamic_admin_forms` templates are found via using `APP_DIRS` setting:
|
|
183
|
-
```python
|
|
184
|
-
TEMPLATES = [
|
|
185
|
-
{
|
|
186
|
-
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
187
|
-
'APP_DIRS': True,
|
|
188
|
-
...
|
|
189
|
-
},
|
|
190
|
-
]
|
|
191
|
-
```
|
|
192
|
-
- Run `python manage.py collectstatic` to include this apps Javascript code in your `settings.STATIC_ROOT` directory
|
|
193
|
-
""",
|
|
194
|
-
),
|
|
195
|
-
supported_django_versions=SUPPORTED_DJANGO_VERSIONS,
|
|
196
|
-
supported_python_versions=SUPPORTED_PYTHON_VERSIONS,
|
|
197
|
-
dependencies=[
|
|
198
|
-
"django >=3.2",
|
|
199
|
-
],
|
|
200
|
-
optional_dependencies={
|
|
201
|
-
"dev": [
|
|
202
|
-
*DEV_DEPENDENCIES,
|
|
203
|
-
"unittest-parametrize~=1.4",
|
|
204
|
-
],
|
|
205
|
-
},
|
|
206
|
-
ruff_ignore_list=[],
|
|
207
|
-
)
|
|
1
|
+
# django-dynamic-admin-forms
|
|
2
|
+
|
|
3
|
+
Add simple interactions to the otherwise static django admin.
|
|
4
|
+
|
|
5
|
+
[](https://postimg.cc/Yv9ZJdWp)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
- Install the package via pip:
|
|
10
|
+
|
|
11
|
+
```pip install django-dynamic-admin-forms```
|
|
12
|
+
|
|
13
|
+
or via pipenv:
|
|
14
|
+
|
|
15
|
+
```pipenv install django-dynamic-admin-forms```
|
|
16
|
+
- Add the module to `INSTALLED_APPS`:
|
|
17
|
+
```python
|
|
18
|
+
INSTALLED_APPS = (
|
|
19
|
+
'django_dynamic_admin_forms',
|
|
20
|
+
'django.contrib.admin',
|
|
21
|
+
)
|
|
22
|
+
```
|
|
23
|
+
Ensure that the `dynamic_admin_forms` comes before the
|
|
24
|
+
default `django.contrib.admin` in the list of installed apps,
|
|
25
|
+
because otherwise the templates, which are overwritten by `dynamic_admin_forms`
|
|
26
|
+
won't be found.
|
|
27
|
+
- Ensure that the `dynamic_admin_forms` templates are found via using `APP_DIRS` setting:
|
|
28
|
+
```python
|
|
29
|
+
TEMPLATES = [
|
|
30
|
+
{
|
|
31
|
+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
32
|
+
'APP_DIRS': True,
|
|
33
|
+
},
|
|
34
|
+
]
|
|
35
|
+
```
|
|
36
|
+
- Run `python manage.py collectstatic` to include this apps Javascript code in your `settings.STATIC_ROOT` directory
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
- Add the `django_dynamic_admin_forms.DynamicModelAdminMixin` to your admin classes
|
|
40
|
+
- Add the `django_dynamic_admin_forms.urls` to your urls
|
|
41
|
+
```python
|
|
42
|
+
from django.contrib import admin
|
|
43
|
+
from django.urls import path, include
|
|
44
|
+
|
|
45
|
+
urlpatterns = [
|
|
46
|
+
path("admin/", admin.site.urls),
|
|
47
|
+
path("dynamic-admin-form/", include("django_dynamic_admin_forms.urls")),
|
|
48
|
+
]
|
|
49
|
+
```
|
|
50
|
+
- In addition to the standard `fields` declaration, specify a list of `dynamic_fields`
|
|
51
|
+
- For each dynamic field, add a method `get_dynamic_{field_name}_field` to the admin
|
|
52
|
+
- Input: `data: Dict[str, Any]` - the cleaned form data
|
|
53
|
+
- Output:
|
|
54
|
+
- `queryset: Optional[Queryset]` - The values to select from
|
|
55
|
+
- `value: Any` - The value, the field should have (must be compatible to the field type)
|
|
56
|
+
- `hidden: Bool` - True, if field should be hidden
|
|
57
|
+
|
|
58
|
+
- A rather non-sensical example:
|
|
59
|
+
```python
|
|
60
|
+
from django.contrib import admin
|
|
61
|
+
|
|
62
|
+
from .models import MyModel
|
|
63
|
+
from django_dynamic_admin_forms.admin import DynamicModelAdminMixin
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@admin.register(MyModel)
|
|
67
|
+
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
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## How it works
|
|
86
|
+
Whenever a dynamic form changes, an event handler makes a request to a special endpoint, which returns new HTML to swap
|
|
87
|
+
into the existing form. This new HTML is directly generated by `django.contrib.admin`, so we only have to set the
|
|
88
|
+
outerHTML of the correct HTML elements to update the form.
|
|
89
|
+
|
|
90
|
+
## Limitations
|
|
91
|
+
- does not work in conjunction with inlines
|
|
92
|
+
- does not validate that the selected value is really part of the original queryset
|
|
93
|
+
- if anybody can modify your DOM, they could potentially inject invalid values
|
|
94
|
+
- you have to write `Model.clean()` methods to guard against that
|
|
95
|
+
- only tested with Django 3.2
|
|
96
|
+
|
|
97
|
+
## Development
|
|
98
|
+
|
|
99
|
+
For local development, create a virtual environment
|
|
100
|
+
in the `testproj` folder:
|
|
101
|
+
```shell
|
|
102
|
+
$ cd testproj
|
|
103
|
+
$ python3 -m venv .venv
|
|
104
|
+
$ source .venv/bin/activate
|
|
105
|
+
$ cd ..
|
|
106
|
+
$ flit install --symlink
|
|
107
|
+
```
|
|
108
|
+
Now the package should be available in your virtual environment
|
|
109
|
+
and any changes should be directly visible.
|
|
110
|
+
|
|
111
|
+
Alternatively, copy the directory `dynamic_admin_forms`
|
|
112
|
+
into any normal django project, so that the python interpreter
|
|
113
|
+
finds the local version instead of the installed (old) version.
|
|
114
|
+
|
|
115
|
+
## Running E2E tests
|
|
116
|
+
|
|
117
|
+
To run end-to-end tests locally:
|
|
118
|
+
```shell
|
|
119
|
+
$ cd testproj
|
|
120
|
+
$ python manage.py runserver 0.0.0.0:8000 & # start server
|
|
121
|
+
$ python manage.py loaddata fixtures/fixtures-dev.json
|
|
122
|
+
$ cd ../e2e
|
|
123
|
+
$ yarn install # or npm install (only needed first time)
|
|
124
|
+
$ yarn cypress # or npm run cypress
|
|
125
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
## Installation
|
|
2
|
+
|
|
3
|
+
- Install the package via pip:
|
|
4
|
+
|
|
5
|
+
`pip install django-dynamic-admin-forms`
|
|
6
|
+
|
|
7
|
+
or via pipenv:
|
|
8
|
+
|
|
9
|
+
`pipenv install django-dynamic-admin-forms`
|
|
10
|
+
|
|
11
|
+
- Add the module to `INSTALLED_APPS`:
|
|
12
|
+
```python
|
|
13
|
+
INSTALLED_APPS = (
|
|
14
|
+
'django_dynamic_admin_forms',
|
|
15
|
+
'django.contrib.admin',
|
|
16
|
+
)
|
|
17
|
+
```
|
|
18
|
+
Ensure that the `dynamic_admin_forms` comes before the
|
|
19
|
+
default `django.contrib.admin` in the list of installed apps,
|
|
20
|
+
because otherwise the templates, which are overwritten by `dynamic_admin_forms`
|
|
21
|
+
won't be found.
|
|
22
|
+
|
|
23
|
+
- Ensure that the `dynamic_admin_forms` templates are found via using `APP_DIRS` setting:
|
|
24
|
+
```python
|
|
25
|
+
TEMPLATES = [
|
|
26
|
+
{
|
|
27
|
+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
|
28
|
+
'APP_DIRS': True,
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- Run `python manage.py collectstatic` to include this apps Javascript code in your `settings.STATIC_ROOT` directory
|
{django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/.pre-commit-config.yaml
RENAMED
|
@@ -11,6 +11,14 @@ repos:
|
|
|
11
11
|
# Run the Ruff formatter.
|
|
12
12
|
- id: ruff-format
|
|
13
13
|
|
|
14
|
+
- repo: https://github.com/adamchainz/blacken-docs
|
|
15
|
+
rev: 1.16.0
|
|
16
|
+
hooks:
|
|
17
|
+
- id: blacken-docs
|
|
18
|
+
additional_dependencies:
|
|
19
|
+
- black==24.4.2
|
|
20
|
+
files: '(?:README\.md|docs\/.*\.(?:md|rst))'
|
|
21
|
+
|
|
14
22
|
- repo: https://github.com/asottile/pyupgrade
|
|
15
23
|
rev: v3.16.0
|
|
16
24
|
hooks:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: django-dynamic-admin-forms
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.4
|
|
4
4
|
Summary: Add simple dynamic interaction to the otherwise static django admin.
|
|
5
5
|
Author-email: Ambient Digital <hello@ambient.digital>, Fabian Binz <fabian.binz@ambient.digital>
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -34,7 +34,7 @@ Requires-Dist: sphinx-rtd-theme~=2.0 ; extra == "dev"
|
|
|
34
34
|
Requires-Dist: m2r2==0.3.3.post2 ; extra == "dev"
|
|
35
35
|
Requires-Dist: mistune<2.0.0 ; extra == "dev"
|
|
36
36
|
Requires-Dist: flit~=3.9 ; extra == "dev"
|
|
37
|
-
Requires-Dist: ambient-package-update~=24.6.
|
|
37
|
+
Requires-Dist: ambient-package-update~=24.6.4 ; extra == "dev"
|
|
38
38
|
Requires-Dist: unittest-parametrize~=1.4 ; extra == "dev"
|
|
39
39
|
Project-URL: Bugtracker, https://github.com/ambient-innovation/django-dynamic-admin/issues
|
|
40
40
|
Project-URL: Changelog, https://django-dynamic-admin-forms.readthedocs.io/en/latest/features/changelog.html
|
|
@@ -76,10 +76,8 @@ Add simple interactions to the otherwise static django admin.
|
|
|
76
76
|
- Add the module to `INSTALLED_APPS`:
|
|
77
77
|
```python
|
|
78
78
|
INSTALLED_APPS = (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
'django.contrib.admin'
|
|
82
|
-
...
|
|
79
|
+
"django_dynamic_admin_forms",
|
|
80
|
+
"django.contrib.admin",
|
|
83
81
|
)
|
|
84
82
|
```
|
|
85
83
|
Ensure that the `dynamic_admin_forms` comes before the
|
|
@@ -90,9 +88,8 @@ Add simple interactions to the otherwise static django admin.
|
|
|
90
88
|
```python
|
|
91
89
|
TEMPLATES = [
|
|
92
90
|
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
...
|
|
91
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
92
|
+
"APP_DIRS": True,
|
|
96
93
|
},
|
|
97
94
|
]
|
|
98
95
|
```
|
|
@@ -106,8 +103,8 @@ Add simple interactions to the otherwise static django admin.
|
|
|
106
103
|
from django.urls import path, include
|
|
107
104
|
|
|
108
105
|
urlpatterns = [
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
path("admin/", admin.site.urls),
|
|
107
|
+
path("dynamic-admin-form/", include("django_dynamic_admin_forms.urls")),
|
|
111
108
|
]
|
|
112
109
|
```
|
|
113
110
|
- In addition to the standard `fields` declaration, specify a list of `dynamic_fields`
|
|
@@ -128,20 +125,20 @@ Add simple interactions to the otherwise static django admin.
|
|
|
128
125
|
|
|
129
126
|
@admin.register(MyModel)
|
|
130
127
|
class MyModelAdmin(DynamicModelAdminMixin, admin.ModelAdmin):
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
128
|
+
fields = ("name", "city")
|
|
129
|
+
dynamic_fields = ("city",)
|
|
130
|
+
|
|
131
|
+
def get_dynamic_city_field(self, data):
|
|
132
|
+
# automatically choose first city that matches first letter of name
|
|
133
|
+
name = data.get("name")
|
|
134
|
+
if not name:
|
|
135
|
+
queryset = City.objects.all()
|
|
136
|
+
value = data.get("city")
|
|
137
|
+
else:
|
|
138
|
+
queryset = City.objects.filter(name__startswith=name[0])
|
|
139
|
+
value = queryset.first()
|
|
140
|
+
hidden = not queryset.exists()
|
|
141
|
+
return queryset, value, hidden
|
|
145
142
|
```
|
|
146
143
|
|
|
147
144
|
|
|
@@ -187,29 +184,39 @@ $ yarn install # or npm install (only needed first time)
|
|
|
187
184
|
$ yarn cypress # or npm run cypress
|
|
188
185
|
```
|
|
189
186
|
|
|
190
|
-
|
|
191
187
|
## Installation
|
|
192
188
|
|
|
193
189
|
- Install the package via pip:
|
|
194
190
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
or via pipenv:
|
|
191
|
+
`pip install django-dynamic-admin-forms`
|
|
198
192
|
|
|
199
|
-
|
|
193
|
+
or via pipenv:
|
|
200
194
|
|
|
201
|
-
|
|
195
|
+
`pipenv install django-dynamic-admin-forms`
|
|
202
196
|
|
|
203
|
-
|
|
197
|
+
- Add the module to `INSTALLED_APPS`:
|
|
198
|
+
```python
|
|
204
199
|
INSTALLED_APPS = (
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
"django_dynamic_admin_forms",
|
|
201
|
+
"django.contrib.admin",
|
|
207
202
|
)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
203
|
+
```
|
|
204
|
+
Ensure that the `dynamic_admin_forms` comes before the
|
|
205
|
+
default `django.contrib.admin` in the list of installed apps,
|
|
206
|
+
because otherwise the templates, which are overwritten by `dynamic_admin_forms`
|
|
207
|
+
won't be found.
|
|
211
208
|
|
|
209
|
+
- Ensure that the `dynamic_admin_forms` templates are found via using `APP_DIRS` setting:
|
|
210
|
+
```python
|
|
211
|
+
TEMPLATES = [
|
|
212
|
+
{
|
|
213
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
214
|
+
"APP_DIRS": True,
|
|
215
|
+
},
|
|
216
|
+
]
|
|
217
|
+
```
|
|
212
218
|
|
|
219
|
+
- Run `python manage.py collectstatic` to include this apps Javascript code in your `settings.STATIC_ROOT` directory
|
|
213
220
|
|
|
214
221
|
## Contribute
|
|
215
222
|
|
|
@@ -31,10 +31,8 @@ Add simple interactions to the otherwise static django admin.
|
|
|
31
31
|
- Add the module to `INSTALLED_APPS`:
|
|
32
32
|
```python
|
|
33
33
|
INSTALLED_APPS = (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'django.contrib.admin'
|
|
37
|
-
...
|
|
34
|
+
"django_dynamic_admin_forms",
|
|
35
|
+
"django.contrib.admin",
|
|
38
36
|
)
|
|
39
37
|
```
|
|
40
38
|
Ensure that the `dynamic_admin_forms` comes before the
|
|
@@ -45,9 +43,8 @@ Add simple interactions to the otherwise static django admin.
|
|
|
45
43
|
```python
|
|
46
44
|
TEMPLATES = [
|
|
47
45
|
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
...
|
|
46
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
47
|
+
"APP_DIRS": True,
|
|
51
48
|
},
|
|
52
49
|
]
|
|
53
50
|
```
|
|
@@ -61,8 +58,8 @@ Add simple interactions to the otherwise static django admin.
|
|
|
61
58
|
from django.urls import path, include
|
|
62
59
|
|
|
63
60
|
urlpatterns = [
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
path("admin/", admin.site.urls),
|
|
62
|
+
path("dynamic-admin-form/", include("django_dynamic_admin_forms.urls")),
|
|
66
63
|
]
|
|
67
64
|
```
|
|
68
65
|
- In addition to the standard `fields` declaration, specify a list of `dynamic_fields`
|
|
@@ -83,20 +80,20 @@ Add simple interactions to the otherwise static django admin.
|
|
|
83
80
|
|
|
84
81
|
@admin.register(MyModel)
|
|
85
82
|
class MyModelAdmin(DynamicModelAdminMixin, admin.ModelAdmin):
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
83
|
+
fields = ("name", "city")
|
|
84
|
+
dynamic_fields = ("city",)
|
|
85
|
+
|
|
86
|
+
def get_dynamic_city_field(self, data):
|
|
87
|
+
# automatically choose first city that matches first letter of name
|
|
88
|
+
name = data.get("name")
|
|
89
|
+
if not name:
|
|
90
|
+
queryset = City.objects.all()
|
|
91
|
+
value = data.get("city")
|
|
92
|
+
else:
|
|
93
|
+
queryset = City.objects.filter(name__startswith=name[0])
|
|
94
|
+
value = queryset.first()
|
|
95
|
+
hidden = not queryset.exists()
|
|
96
|
+
return queryset, value, hidden
|
|
100
97
|
```
|
|
101
98
|
|
|
102
99
|
|
|
@@ -142,29 +139,39 @@ $ yarn install # or npm install (only needed first time)
|
|
|
142
139
|
$ yarn cypress # or npm run cypress
|
|
143
140
|
```
|
|
144
141
|
|
|
145
|
-
|
|
146
142
|
## Installation
|
|
147
143
|
|
|
148
144
|
- Install the package via pip:
|
|
149
145
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
or via pipenv:
|
|
146
|
+
`pip install django-dynamic-admin-forms`
|
|
153
147
|
|
|
154
|
-
|
|
148
|
+
or via pipenv:
|
|
155
149
|
|
|
156
|
-
|
|
150
|
+
`pipenv install django-dynamic-admin-forms`
|
|
157
151
|
|
|
158
|
-
|
|
152
|
+
- Add the module to `INSTALLED_APPS`:
|
|
153
|
+
```python
|
|
159
154
|
INSTALLED_APPS = (
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
"django_dynamic_admin_forms",
|
|
156
|
+
"django.contrib.admin",
|
|
162
157
|
)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
158
|
+
```
|
|
159
|
+
Ensure that the `dynamic_admin_forms` comes before the
|
|
160
|
+
default `django.contrib.admin` in the list of installed apps,
|
|
161
|
+
because otherwise the templates, which are overwritten by `dynamic_admin_forms`
|
|
162
|
+
won't be found.
|
|
166
163
|
|
|
164
|
+
- Ensure that the `dynamic_admin_forms` templates are found via using `APP_DIRS` setting:
|
|
165
|
+
```python
|
|
166
|
+
TEMPLATES = [
|
|
167
|
+
{
|
|
168
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
169
|
+
"APP_DIRS": True,
|
|
170
|
+
},
|
|
171
|
+
]
|
|
172
|
+
```
|
|
167
173
|
|
|
174
|
+
- Run `python manage.py collectstatic` to include this apps Javascript code in your `settings.STATIC_ROOT` directory
|
|
168
175
|
|
|
169
176
|
## Contribute
|
|
170
177
|
|
|
File without changes
|
|
File without changes
|
{django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/.github/workflows/ci.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/docs/features/changelog.rst
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/e2e/cypress/plugins/index.js
RENAMED
|
File without changes
|
|
File without changes
|
{django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/e2e/cypress/support/index.js
RENAMED
|
File without changes
|
{django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/e2e/cypress/support/paths.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/fixtures/fixtures-dev.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/testapp/migrations/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/tests/test_admin_generic.py
RENAMED
|
File without changes
|
{django_dynamic_admin_forms-3.0.2 → django_dynamic_admin_forms-3.0.4}/tests/test_admin_unit.py
RENAMED
|
File without changes
|