Skip to content

Commit f5a1309

Browse files
committed
Updates for latest Django supported versions
1 parent 8329c90 commit f5a1309

16 files changed

+75
-73
lines changed

.github/workflows/main.yml

+5-9
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,20 @@ on:
99
jobs:
1010
tests:
1111
name: Python ${{ matrix.python-version }}
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-latest
1313

1414
strategy:
1515
matrix:
16-
python-version:
17-
- 3.6
18-
- 3.7
19-
- 3.8
20-
- 3.9
16+
python-version: ["3.10", "3.11", "3.12", "3.13"]
2117

2218
steps:
23-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v4
2420

25-
- uses: actions/setup-python@v2
21+
- uses: actions/setup-python@v5
2622
with:
2723
python-version: ${{ matrix.python-version }}
2824

29-
- uses: actions/cache@v2
25+
- uses: actions/cache@v4
3026
with:
3127
path: ~/.cache/pip
3228
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/*.txt') }}

.github/workflows/pre-commit.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ on:
88

99
jobs:
1010
pre-commit:
11-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515
with:
1616
fetch-depth: 0
1717

18-
- uses: actions/setup-python@v2
18+
- uses: actions/setup-python@v5
1919

20-
- uses: pre-commit/action@v2.0.0
20+
- uses: pre-commit/action@v3.0.1
2121
with:
2222
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ html/
99
htmlcov/
1010
*.egg-info/
1111
.tox/
12+
/temp
13+
/venv

.pre-commit-config.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.3.0
3+
rev: v5.0.0
44
hooks:
55
- id: check-added-large-files
66
- id: check-case-conflict
@@ -11,24 +11,25 @@ repos:
1111
- id: end-of-file-fixer
1212
- id: trailing-whitespace
1313
- repo: https://github.com/psf/black
14-
rev: 22.8.0
14+
rev: 25.1.0
1515
hooks:
1616
- id: black
1717
language_version: python3
1818
- repo: https://github.com/pycqa/isort
19-
rev: 5.10.1
19+
rev: 6.0.1
2020
hooks:
2121
- id: isort
2222
- repo: https://github.com/PyCQA/flake8
23-
rev: 5.0.4
23+
rev: 7.1.2
2424
hooks:
2525
- id: flake8
2626
additional_dependencies:
2727
- flake8-bugbear
2828
- flake8-comprehensions
2929
- flake8-tidy-imports
3030
- repo: https://github.com/mgedmin/check-manifest
31-
rev: "0.48"
31+
rev: "0.50"
3232
hooks:
3333
- id: check-manifest
3434
args: [--no-build-isolation]
35+
additional_dependencies: [setuptools, wheel]

docs/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ Writing the same code with `django-vanilla-views`, you'd instead arrive at a sim
9090

9191
## Requirements
9292

93-
* **Django**: 2.2, 3.0, 3.1, 3.2
94-
* **Python**: 3.6, 3.7, 3.8, 3.9
93+
* **Django**: 4.2, 5.0, 5.1, 5.2
94+
* **Python**: 3.10, 3.11, 3.12, 3.13
9595

9696
## Installation
9797

example/example/notes/migrations/0001_initial.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
class Migration(migrations.Migration):
5-
65
initial = True
76

87
dependencies = []

example/manage.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
23
import os
34
import sys
45

5-
if __name__ == "__main__":
6+
7+
def main():
8+
"""Run administrative tasks."""
69
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
719

8-
from django.core.management import execute_from_command_line
920

10-
execute_from_command_line(sys.argv)
21+
if __name__ == "__main__":
22+
main()

example/requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Django>=1.8
2-
django-vanilla-views==1.0.4
1+
Django>=4.2
2+
django-vanilla-views>=3.1.0

manage.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
23
import os
34
import sys
45

5-
if __name__ == "__main__":
6+
7+
def main():
8+
"""Run administrative tasks."""
69
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testsettings")
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
719

8-
from django.core.management import execute_from_command_line
920

10-
execute_from_command_line(sys.argv)
21+
if __name__ == "__main__":
22+
main()

mkdocs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
next_url_map[path] = rel + path_list[idx + 1][:-3] + suffix
6262

6363

64-
for (dirpath, _dirnames, filenames) in os.walk(docs_dir):
64+
for dirpath, _dirnames, filenames in os.walk(docs_dir):
6565
relative_dir = dirpath.replace(docs_dir, "").lstrip(os.path.sep)
6666
build_dir = os.path.join(html_dir, relative_dir)
6767

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools >= 40.6.0", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[tool.black]
6-
target-version = ['py36']
6+
target-version = ['py310']
77

88
[tool.isort]
99
profile = "black"

setup.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ def get_package_data(package):
8383
"Changelog": "http://django-vanilla-views.org/topics/release-notes",
8484
"Repository": "https://github.com/tomchristie/django-vanilla-views/",
8585
},
86-
python_requires=">=3.6",
86+
python_requires=">=3.10",
8787
install_requires=[],
8888
classifiers=[
8989
"Development Status :: 5 - Production/Stable",
9090
"Environment :: Web Environment",
9191
"Framework :: Django",
92-
"Framework :: Django :: 2.2",
93-
"Framework :: Django :: 3.0",
94-
"Framework :: Django :: 3.1",
95-
"Framework :: Django :: 3.2",
92+
"Framework :: Django :: 4.2",
93+
"Framework :: Django :: 5.0",
94+
"Framework :: Django :: 5.1",
95+
"Framework :: Django :: 5.2",
9696
"Intended Audience :: Developers",
9797
"License :: OSI Approved :: BSD License",
9898
"Operating System :: OS Independent",

testsettings.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import django
2-
31
DATABASES = {
42
"default": {
53
"ENGINE": "django.db.backends.sqlite3",
@@ -9,18 +7,13 @@
97

108
INSTALLED_APPS = ("vanilla",)
119

12-
if django.VERSION >= (1, 10):
13-
MIDDLEWARE = [
14-
"django.middleware.common.CommonMiddleware",
15-
"django.middleware.csrf.CsrfViewMiddleware",
16-
]
17-
else:
18-
MIDDLEWARE_CLASSES = [
19-
"django.middleware.common.CommonMiddleware",
20-
"django.middleware.csrf.CsrfViewMiddleware",
21-
]
10+
MIDDLEWARE = [
11+
"django.middleware.common.CommonMiddleware",
12+
"django.middleware.csrf.CsrfViewMiddleware",
13+
]
2214

2315
SECRET_KEY = "abcde12345"
2416

25-
if django.VERSION >= (3, 2):
26-
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
17+
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
18+
19+
USE_TZ = False

tox.ini

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
[tox]
22
isolated_build = True
33
envlist =
4-
py36-django{22,30,31,32}
5-
py37-django{22,30,31,32}
6-
py38-django{30,31,32}
7-
py39-django{30,31,32}
4+
py{310,311,312}-django{42,50,51,52}
5+
py313-django{51,52}
86

97
[testenv]
108
commands = python -W error::DeprecationWarning -W error::PendingDeprecationWarning manage.py test
119
deps =
12-
django22: django>=2.2,<3.0
13-
django30: django>=3.0,<3.1
14-
django31: django>=3.1,<3.2
15-
django32: django>=3.2,<4.0
10+
django42: django>=4.2,<5.0
11+
django50: django>=5.0,<5.1
12+
django51: django>=5.1,<5.2
13+
django52: django>=5.2b1,<6.0

vanilla/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
)
1111
from vanilla.views import FormView, GenericView, TemplateView
1212

13-
__version__ = "3.0.0"
13+
__version__ = "3.1.0"
1414
__all__ = (
1515
"View",
1616
"GenericView",

vanilla/tests.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@ def setUp(self):
5252
self.factory = RequestFactory()
5353
super(BaseTestCase, self).setUp()
5454

55-
def assertFormError(self, response, form, field, errors, msg_prefix=""):
56-
# Hack to get around the fact that we're using request factory,
57-
# instead of the full test client.
58-
response.context = response.context_data
59-
return super(BaseTestCase, self).assertFormError(
60-
response, form, field, errors, msg_prefix
61-
)
62-
6355
def assertContext(self, response, expected):
6456
# Ensure the keys all match.
6557
# Note that this style ensures we get nice descriptive failures.
@@ -301,8 +293,7 @@ def test_create_failed(self):
301293
self.assertEqual(response.status_code, 200)
302294
self.assertEqual(response.template_name, ["vanilla/example_form.html"])
303295
self.assertFormError(
304-
response,
305-
"form",
296+
response.context_data["form"],
306297
"text",
307298
["Ensure this value has at most 10 characters (it has 700)."],
308299
)
@@ -379,8 +370,7 @@ def test_update_failed(self):
379370
self.assertEqual(response.status_code, 200)
380371
self.assertEqual(response.template_name, ["vanilla/example_form.html"])
381372
self.assertFormError(
382-
response,
383-
"form",
373+
response.context_data["form"],
384374
"text",
385375
["Ensure this value has at most 10 characters (it has 700)."],
386376
)
@@ -614,8 +604,7 @@ def test_form_failure(self):
614604
self.assertEqual(response.status_code, 200)
615605
self.assertEqual(response.template_name, ["example.html"])
616606
self.assertFormError(
617-
response,
618-
"form",
607+
response.context_data["form"],
619608
"text",
620609
["Ensure this value has at most 10 characters (it has 700)."],
621610
)

0 commit comments

Comments
 (0)