Skip to content

Commit 385f34b

Browse files
Django version check (#77)
* refactor: replace pkg_resources-based Django version check Fixes /django_excel/_compact.py:1: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. * chore: exclude .venv from flake8 check * chore: update changelog.yml * chore: make format
1 parent a17fea3 commit 385f34b

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

changelog.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
name: django-excel
22
organisation: pyexcel-webwares
33
releases:
4+
- changes:
5+
- action: 'Change:'
6+
details:
7+
- Replace pkg_resources-based Django version check with django.get_version()
8+
- Exclude .venv from flake8 check to simplify development
9+
date: 31.10.2025
10+
version: 0.0.13
411
- changes:
512
- action: 'Change:'
613
details:

django_excel/__init__.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""
2-
django_excel
3-
~~~~~~~~~~~~~~~~~~~
2+
django_excel
3+
~~~~~~~~~~~~~~~~~~~
44
5-
A django middleware that provides one application programming interface
6-
to read and write data in different excel file formats
5+
A django middleware that provides one application programming interface
6+
to read and write data in different excel file formats
77
8-
:copyright: (c) 2015 by Onni Software Ltd.
9-
:license: New BSD License
8+
:copyright: (c) 2015 by Onni Software Ltd.
9+
:license: New BSD License
1010
"""
11+
1112
import pyexcel as pe
1213
import pyexcel_webio as webio
1314
from django.core.files.uploadedfile import (
@@ -174,21 +175,22 @@ def _make_response(content, content_type, status, file_name=None):
174175
if PY2_VERSION and isinstance(file_name, unicode):
175176
file_name = file_name.encode("utf-8")
176177
url_encoded_file_name = urllib_quote(file_name)
177-
response[
178-
"Content-Disposition"
179-
] = "attachment; filename=%s;filename*=utf-8''%s" % (
180-
url_encoded_file_name,
181-
url_encoded_file_name,
178+
response["Content-Disposition"] = (
179+
"attachment; filename=%s;filename*=utf-8''%s"
180+
% (
181+
url_encoded_file_name,
182+
url_encoded_file_name,
183+
)
182184
)
183185
return response
184186

185187

186188
webio.init_webio(_make_response)
187189

188190

191+
from pyexcel_webio import make_response_from_array # noqa
189192
from pyexcel_webio import (
190193
make_response,
191-
make_response_from_array, # noqa
192194
make_response_from_book_dict,
193195
make_response_from_dict,
194196
make_response_from_query_sets,

django_excel/_compact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from distutils.version import LooseVersion
22

3-
import pkg_resources
3+
from django import get_version
44

55
try:
66
# if in py2
@@ -14,7 +14,7 @@
1414
PY2_VERSION = False
1515

1616

17-
django_version = pkg_resources.get_distribution("django").version
17+
django_version = get_version()
1818

1919

2020
DJANGO_ONE_SIX = LooseVersion(django_version) < LooseVersion(

lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pip install flake8
2-
flake8 --exclude=.moban.d,docs,setup.py --ignore=F401,E402,E501,W503 --builtins=unicode,xrange,long . && python setup.py checkdocs
2+
flake8 --exclude=.venv,.moban.d,docs,setup.py --ignore=F401,E402,E501,W503 --builtins=unicode,xrange,long . && python setup.py checkdocs

0 commit comments

Comments
 (0)