Skip to content

Commit ad77595

Browse files
committed
Use external modeladmin package where available
1 parent 6a20507 commit ad77595

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

README.rst

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,32 @@ This module supports the creation of A/B testing experiments within a Wagtail si
1111
Installation
1212
------------
1313

14-
wagtail-experiments is compatible with Wagtail 4.1 to 5.1, and Django 3.2 to 4.2. To install::
14+
wagtail-experiments is compatible with Wagtail 4.1 to 5.2, and Django 3.2 to 4.2. It depends on the Wagtail ModelAdmin module, which is available as an external package as of Wagtail 5.0; we recommend using this rather than the bundled `wagtail.contrib.modeladmin` module to avoid deprecation warnings. The external package will be required as of Wagtail 6.0.
15+
16+
### On Wagtail 5.0 and above
17+
18+
To install::
19+
20+
pip install wagtail-experiments wagtail-modeladmin
21+
22+
and ensure that the apps ``wagtail_modeladmin`` and ``experiments`` are included in your project's ``INSTALLED_APPS``:
23+
24+
.. code-block:: python
25+
26+
INSTALLED_APPS = [
27+
# ...
28+
'wagtail_modeladmin',
29+
'experiments',
30+
# ...
31+
]
32+
33+
Then migrate::
34+
35+
./manage.py migrate
36+
37+
### On Wagtail 4.x
38+
39+
To install::
1540

1641
pip install wagtail-experiments
1742

experiments/wagtail_hooks.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44

55
from django.utils.translation import gettext_lazy as _
66
from experiments import admin_urls
7-
from wagtail.contrib.modeladmin.helpers import ButtonHelper
8-
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
9-
from wagtail.contrib.modeladmin.views import CreateView, EditView
107
from wagtail import hooks
118

9+
try:
10+
from wagtail_modeladmin.helpers import ButtonHelper
11+
from wagtail_modeladmin.options import ModelAdmin, modeladmin_register
12+
from wagtail_modeladmin.views import CreateView, EditView
13+
except ImportError:
14+
from wagtail.contrib.modeladmin.helpers import ButtonHelper
15+
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
16+
from wagtail.contrib.modeladmin.views import CreateView, EditView
17+
18+
1219
from .models import Experiment
1320
from .utils import get_user_id, impersonate_other_page
1421

tests/settings.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33

44
from wagtail import VERSION as WAGTAIL_VERSION
55

6+
try:
7+
import wagtail_modeladmin
8+
except ImportError:
9+
HAS_MODELADMIN_PACKAGE = False
10+
else:
11+
HAS_MODELADMIN_PACKAGE = True
12+
13+
614
DATABASES = {
715
'default': {
816
'ENGINE': os.environ.get('DATABASE_ENGINE', 'django.db.backends.sqlite3'),
@@ -64,7 +72,7 @@
6472
'experiments',
6573
'tests',
6674

67-
'wagtail.contrib.modeladmin',
75+
'wagtail_modeladmin' if HAS_MODELADMIN_PACKAGE else 'wagtail.contrib.modeladmin',
6876
'wagtail.search',
6977
'wagtail.sites',
7078
'wagtail.users',

0 commit comments

Comments
 (0)