Skip to content

Commit 20cb27c

Browse files
Merge pull request #107 from ceresnam/master
added support for django 5
2 parents d0a8652 + 648f81b commit 20cb27c

8 files changed

Lines changed: 73 additions & 21 deletions

File tree

.github/workflows/tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
python-version: ['3.7', '3.8', '3.9', '3.10']
14+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
1515

1616
steps:
1717
- uses: actions/checkout@v3

.travis.yml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ dist: xenial
22
language: python
33
sudo: false
44
python:
5-
- "3.6"
6-
- "3.7"
75
- "3.8"
6+
- "3.9"
7+
- "3.10"
8+
- "3.11"
9+
- "3.12"
10+
- "3.13"
811
cache:
912
pip: true
1013
install:
@@ -14,16 +17,38 @@ script:
1417
- tox
1518
env:
1619
matrix:
17-
- DJANGO="2.2"
1820
- DJANGO="3.0"
21+
- DJANGO="4.0"
22+
- DJANGO="5.0"
1923
- DJANGO="master"
2024
matrix:
2125
allow_failures:
22-
- python: "3.6"
23-
env: DJANGO="master"
24-
- python: "3.7"
25-
env: DJANGO="master"
2626
- python: "3.8"
27+
env: DJANGO="5.0"
28+
- python: "3.8"
29+
env: DJANGO="master"
30+
31+
- python: "3.9"
32+
env: DJANGO="5.0"
33+
- python: "3.9"
2734
env: DJANGO="master"
35+
36+
- python: "3.10"
37+
env: DJANGO="3.0"
38+
39+
- python: "3.11"
40+
env: DJANGO="3.0"
41+
- python: "3.11"
42+
env: DJANGO="4.0"
43+
44+
- python: "3.12"
45+
env: DJANGO="3.0"
46+
- python: "3.12"
47+
env: DJANGO="4.0"
48+
49+
- python: "3.13"
50+
env: DJANGO="3.0"
51+
- python: "3.13"
52+
env: DJANGO="4.0"
2853
after_success:
2954
- codecov

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ django-prices: Django fields for the `prices` module
77

88
* `pip install django-prices`
99
* Add `django_prices` to your `INSTALLED_APPS` at `settings.py`
10-
* Follow `enmerkar` [instructions](https://github.com/Zegocover/enmerkar#using-the-middleware) and update both your `INSTALLED_APPS` and `MIDDLEWARE_CLASSES`.
1110

1211
# Features
1312

django_prices/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class NonDatabaseFieldBase:
2323

2424
is_relation = False
2525
remote_field = None
26+
generated = False
2627

2728
many_to_many = None
2829
many_to_one = None

django_prices/templatetags/prices.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
from babel import support as babel_support
2+
from babel import core as babel_core
13
from django import template
2-
3-
from enmerkar.templatetags.babel import currencyfmt
4+
from django.conf import settings
5+
from django.utils.translation import to_locale, get_language
6+
try:
7+
from pytz import timezone
8+
except ImportError:
9+
timezone = None
410

511
from ..utils.formatting import format_price
612

@@ -14,9 +20,18 @@ def amount(obj, format="text"):
1420
return format_price(obj.amount, obj.currency, html=False)
1521
if format == "html":
1622
return format_price(obj.amount, obj.currency, html=True)
17-
return currencyfmt(obj.amount, obj.currency)
23+
return _get_format().currency(obj.amount, obj.currency)
1824

1925

2026
@register.filter
2127
def discount_amount_for(discount, price):
2228
return discount(price) - price
29+
30+
31+
def _get_format():
32+
locale = babel_core.Locale.parse(to_locale(get_language()))
33+
if timezone:
34+
tzinfo = timezone(settings.TIME_ZONE)
35+
else:
36+
tzinfo = None
37+
return babel_support.Format(locale, tzinfo)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.black]
2-
target_version = ['py34', 'py35', 'py36', 'py37', 'py38']
2+
target_version = ['py38', 'py39', 'py310', 'py311', 'py312', 'py313']
33
include = '\.pyi?$'
44
exclude = '''
55
/(\.git/

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
"License :: OSI Approved :: BSD License",
88
"Operating System :: OS Independent",
99
"Programming Language :: Python",
10-
"Programming Language :: Python :: 3.7",
1110
"Programming Language :: Python :: 3.8",
1211
"Programming Language :: Python :: 3.9",
1312
"Programming Language :: Python :: 3.10",
13+
"Programming Language :: Python :: 3.11",
14+
"Programming Language :: Python :: 3.12",
15+
"Programming Language :: Python :: 3.13",
1416
"Topic :: Internet :: WWW/HTTP",
1517
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
1618
"Topic :: Software Development :: Libraries :: Application Frameworks",
@@ -35,8 +37,7 @@
3537
classifiers=CLASSIFIERS,
3638
install_requires=[
3739
"Babel>=2.2",
38-
"Django>=3.0,<5",
39-
"enmerkar>=0.7.1",
40+
"Django>=3.0,<6",
4041
"prices>=1.0.0",
4142
],
4243
platforms=["any"],

tox.ini

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
[tox]
22
envlist =
3-
py37-django3
4-
py{38,39,310}-django{3,4}
5-
py{38,39,310}-django_master
3+
; https://docs.djangoproject.com/en/dev/releases/3.0/
4+
py{38,39}-django3
5+
; https://docs.djangoproject.com/en/dev/releases/4.0/
6+
py{38,39,310}-django4
7+
; https://docs.djangoproject.com/en/dev/releases/5.0/
8+
py{310,311,312,313}-django5
9+
; https://docs.djangoproject.com/en/dev/releases/6.0/
10+
py{312,313}-django_master
611

712
[gh-actions]
813
python =
9-
3.7: py37
1014
3.8: py38
1115
3.9: py39
1216
3.10: py310
17+
3.11: py311
18+
3.12: py312
19+
3.13: py313
1320

1421
[testenv]
1522
pip_pre = true
1623
deps =
1724
django3: Django>=3.0,<4
1825
django4: Django>=4.0,<5
26+
django5: Django>=5.0,<6
1927
pytest
2028
pytest-cov
2129
pytest-django
@@ -27,16 +35,19 @@ setenv =
2735

2836
[travis]
2937
python =
30-
3.7: py37
3138
3.8: py38
3239
3.9: py39
3340
3.10: py310
41+
3.11: py311
42+
3.12: py312
43+
3.13: py313
3444
unignore_outcomes = True
3545

3646
[travis:env]
3747
DJANGO =
3848
3: django3
3949
4: django4
50+
5: django5
4051
master: django_master
4152

4253
[pytest]

0 commit comments

Comments
 (0)