Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ support django4.2 #33

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.7', '3.8', '3.9', '3.10']
django: ['3.2']
python: ['3.10', '3.11']
django: ['3.2', '4.2']
db: ['postgres', 'sqlite']

name: Run the test suite (Python ${{ matrix.python }}, Django ${{ matrix.django }}, ${{ matrix.db }})
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
python-version: '3.10'

- name: Build sdist and wheel
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9'
python-version: '3.10'
- name: Install dependencies
run: pip install tox
- run: tox
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Installation
Requirements
------------

* Python 3.7 or above
* Python 3.10 or above
* setuptools 30.3.0 or above
* Django 3.2 or newer

Expand Down
1 change: 0 additions & 1 deletion django_loose_fk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = "django_loose_fk.apps.DjangoLooseFkConfig"
2 changes: 1 addition & 1 deletion django_loose_fk/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def validate(self, model, instance, exclude=None, using=DEFAULT_DB_ALIAS):
return check_constraint.validate(model, instance, exclude, using)

def __repr__(self):
return "<%s: field=%r>" % (self.__class__.__name__, self.name)
return "<{}: field={!r}>".format(self.__class__.__name__, self.name)

def __eq__(self, other):
if isinstance(other, FkOrURLFieldConstraint):
Expand Down
2 changes: 1 addition & 1 deletion django_loose_fk/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def clone(self):
return self.__class__(*args, **kwargs)

def deconstruct(self):
path = "%s.%s" % (self.__class__.__module__, self.__class__.__qualname__)
path = "{}.{}".format(self.__class__.__module__, self.__class__.__qualname__)
keywords = {
"fk_field": self.fk_field,
"url_field": self.url_field,
Expand Down
6 changes: 3 additions & 3 deletions django_loose_fk/lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ def as_sql(self, compiler, connection):
if fk_rhs_sql:
fk_rhs_sql = self.get_rhs_op(connection, fk_rhs_sql)
fk_sql = (
"%s %s" % (fk_lhs_sql, fk_rhs_sql),
"{} {}".format(fk_lhs_sql, fk_rhs_sql),
tuple(fk_params) + fk_rhs_params,
)

if url_rhs_sql:
url_rhs_sql = self.get_rhs_op(connection, url_rhs_sql)
url_sql = (
"%s %s" % (url_lhs_sql, url_rhs_sql),
"{} {}".format(url_lhs_sql, url_rhs_sql),
tuple(url_params) + url_rhs_params,
)

Expand All @@ -159,6 +159,6 @@ def as_sql(self, compiler, connection):
return fk_sql

params = url_sql[1] + fk_sql[1]
sql = "(%s OR %s)" % (url_sql[0], fk_sql[0])
sql = "({} OR {})".format(url_sql[0], fk_sql[0])

return sql, params
2 changes: 1 addition & 1 deletion django_loose_fk/virtual_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __set__(self, instance: models.Model, value: List[DictOrUrl]):
class M2MHandler(BaseHandler):
def __get__(self, instance, cls=None) -> QueryList:
raw_data = instance._loose_fk_data.get(self.field_name, [])
assert all((isinstance(url, str) for url in raw_data))
assert all(isinstance(url, str) for url in raw_data)

loaded_data = [
self.loader.load(url=url, model=self.remote_model) for url in raw_data
Expand Down
5 changes: 2 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ classifiers =
Development Status :: 5 - Production/Stable
Framework :: Django
Framework :: Django :: 3.2
Framework :: Django :: 4.2
Intended Audience :: Developers
Operating System :: Unix
Operating System :: MacOS
Operating System :: Microsoft :: Windows
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Topic :: Software Development :: Libraries :: Python Modules

[options]
Expand Down
2 changes: 2 additions & 0 deletions testapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ def get_db():
ROOT_URLCONF = "testapp.urls"

ALLOWED_HOSTS = ["testserver.com"]

USE_TZ = False
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
[tox]
envlist =
py{37,38,39,310}-django32
py{310,311}-django{32,42}
black
isort
; docs
skip_missing_interpreters = true

[gh-actions]
python =
3.10: py310
3.11: py311

[gh-actions:env]
DJANGO =
3.2: django32
4.2: django42

[testenv]
setenv = DJANGO_SETTINGS_MODULE=testapp.settings
Expand All @@ -18,6 +24,7 @@ extras =
coverage
deps =
django32: Django~=3.2.0
django42: Django~=4.2.0
commands =
; check for missing migrations
django-admin makemigrations --dry-run --check
Expand Down
Loading