Skip to content

Commit cddf607

Browse files
committed
Fix RemovedInDjango41Warning deprecation warnings
1 parent 6d6f4ec commit cddf607

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22

33
from setuptools import find_packages, setup
44

5-
from src.wagtail_headless_preview import __version__
6-
75

86
this_directory = path.abspath(path.dirname(__file__))
97
with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
108
long_description = f.read()
119

10+
version = {}
11+
with open(
12+
path.join(this_directory, "src", "wagtail_headless_preview", "version.py")
13+
) as f:
14+
exec(f.read(), version)
1215

1316
setup(
1417
name="wagtail-headless-preview",
15-
version=__version__,
18+
version=version["__version__"],
1619
description="Enhance Wagtail previews in headless setups.",
1720
long_description=long_description,
1821
long_description_content_type="text/markdown",

src/wagtail_headless_preview/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
default_app_config = "wagtail_headless_preview.apps.WagtailHeadlessPreviewConfig"
1+
from django import VERSION as DJANGO_VERSION
22

3-
VERSION = (0, 1, 4)
4-
__version__ = ".".join(map(str, VERSION))
3+
from .version import VERSION, __version__ # noqa
4+
5+
6+
if DJANGO_VERSION >= (3, 2):
7+
# The declaration is only needed for older Django versions
8+
pass
9+
else:
10+
default_app_config = "wagtail_headless_preview.apps.WagtailHeadlessPreviewConfig"
511

612

713
def setup():
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
VERSION = (0, 1, 4)
2+
__version__ = ".".join(map(str, VERSION))

tests/testapp/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
default_app_config = "tests.testapp.apps.WagtailHeadlessPreviewTestsAppConfig"
1+
from django import VERSION as DJANGO_VERSION
2+
3+
4+
if DJANGO_VERSION >= (3, 2):
5+
# The declaration is only needed for older Django versions
6+
pass
7+
else:
8+
default_app_config = "tests.testapp.apps.WagtailHeadlessPreviewTestsAppConfig"

0 commit comments

Comments
 (0)