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

Fix Django 4, 5 and support Python 3.12 #122

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Python package

on:
- push
- pull_request

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox
44 changes: 30 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dist: xenial
sudo: false
dist: focal
branches:
only:
- master
Expand All @@ -8,23 +8,39 @@ cache:
pip: true
directories:
- $HOME/.cache/pip
- $HOME/.cache/poetry
- $HOME/.cache/pre-commit
addons:
apt_packages:
- sqlite3
apt:
packages:
- sqlite3

language: python
python:
- "3.6-dev"
- "3.7-dev"
- "2.7"
- "pypy"
- "pypy3.5-7.0"

- "3.9"
- "3.10"
- "3.11"
- "3.12"
env:
matrix:
- TOXENV=py39-django32
- TOXENV=py310-django32
- TOXENV=py311-django32
- TOXENV=py312-django32
- TOXENV=py39-django42
- TOXENV=py310-django42
- TOXENV=py311-django42
- TOXENV=py312-django42
- TOXENV=py39-djangolatest
- TOXENV=py310-djangolatest
- TOXENV=py311-djangolatest
- TOXENV=py312-djangolatest
install:
- pip install tox-travis
- pip install coveralls==1.1

script: tox
- pip install tox
script:
- tox -e $TOXENV

after_success: coveralls
after_success:
- curl -Os https://uploader.codecov.io/latest/linux/codecov
- chmod +x codecov
- ./codecov -t ${CODECOV_TOKEN}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ lint: ## lint whole library
fi

test: ## run tests quickly with the default Python
py.test -sv \
pytest -sv \
--cov=url_filter \
--cov-report=term-missing \
$(ADDITIONAL_COVERAGE_FLAGS) \
Expand Down
25 changes: 15 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@
Django URL Filter
=================

.. image:: https://badge.fury.io/py/django-url-filter.svg
:target: http://badge.fury.io/py/django-url-filter
.. image:: https://badge.fury.io/py/dj-url-filter.svg
:target: http://badge.fury.io/py/dj-url-filter
.. image:: https://readthedocs.org/projects/django-url-filter/badge/?version=latest
:target: http://django-url-filter.readthedocs.io/en/latest/?badge=latest
.. image:: https://drone.miki725.com/api/badges/miki725/django-url-filter/status.svg
:target: https://drone.miki725.com/miki725/django-url-filter
.. image:: https://codecov.io/gh/miki725/django-url-filter/branch/master/graph/badge.svg
:target: https://codecov.io/gh/miki725/django-url-filter
.. image:: https://codecov.io/gh/enjoy2000/django-url-filter/branch/master/graph/badge.svg
:target: https://codecov.io/gh/enjoy2000/django-url-filter
.. image:: https://img.shields.io/travis/com/enjoy2000/django-url-filter
:alt: Travis (.com)

Django URL Filter provides a safe way to filter data via human-friendly URLs.

* Free software: MIT license
* GitHub: https://github.com/miki725/django-url-filter
* GitHub: https://github.com/enjoy2000/django-url-filter
* Documentation: http://django-url-filter.readthedocs.io/

Notes
-----
This is a forked version of https://github.com//miki725/django-url-filter to add Django 4 support and my other projects.

Overview
--------

Expand All @@ -39,16 +43,17 @@ For example::
Requirements
------------

* Python 2.7, 3.x, pypy or pypy3
* Django 1.8+ (there are plans to support older Django versions)
* Python 3.9+
* Django 3.4+
* Django REST Framework 2 or 3 (only if you want to use DRF integration)
* SQLAlchemy ~1.4 (only if you want to use SQLAlchemy integration)

Installing
----------

Easiest way to install this library is by using ``pip``::

$ pip install django-url-filter
$ pip install dj-url-filter

Usage Example
-------------
Expand Down
2,600 changes: 2,600 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[tool.poetry]
name = "dj-url-filter"
version = "0.4.3"
description = "Django URL Filter provides a safe way to filter data via human-friendly URLs."
authors = ["Hat Dao <enjoy3013@gmail.com>"]
license = "MIT"
readme = "README.rst"
keywords = ["django", "url-filter", "drf"]
classifiers = [
"Framework :: Django",
"Programming Language :: Python :: 3",
"Development Status :: 2 - Pre-Alpha",
]
packages = [{include = "url_filter"}]

[tool.poetry.dependencies]
python = "^3.9"
django = ">=3.2.4"
cached-property = "^1.5.2"

[tool.poetry.dev-dependencies]
tox-poetry-installer = {extras = ["poetry"], version = "^0.10.0"}

[tool.poetry.group.dev.dependencies]
pytest = "^7.2.0"
sqlalchemy = "^1.4.46"
mock = "^5.0.1"
alchemy-mock = "^0.4.3"
black = "^22.12.0"
coreapi = "^2.3.3"
coverage = "^7.0.4"
django-extensions = "^3.2.1"
djangorestframework = "^3.14.0"
flake8 = "^6.0.0"
flake8-bugbear = "^22.12.6"
flake8-comprehensions = "^3.10.1"
importanize = "^0.7.0"
pdbpp = "^0.10.3"
pre-commit = "^2.21.0"
pre-commit-hooks = "^4.4.0"
ptpython = "^3.0.22"
pytest-cov = "^4.0.0"
pytest-django = "^4.5.2"
sphinx-autobuild = "^2021.3.14"
sphinx-rtd-theme = "^1.1.1"
watchdog = "^2.2.1"
werkzeug = "^2.2.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
10 changes: 2 additions & 8 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
-r requirements.txt
-r requirements-release.txt
alchemy-mock
black; python_version > "3.6"
black
coreapi
coverage
django-debug-toolbar
django-debug-toolbar-alchemy
django-extensions
djangorestframework
flake8
flake8-bugbear; python_version > "3.6"
flake8-bugbear
flake8-comprehensions
importanize
mock
Expand All @@ -20,10 +16,8 @@ ptpython
pytest
pytest-cov
pytest-django
sphinx
sphinx-autobuild
sphinx-rtd-theme
sqlalchemy
tox
watchdog
werkzeug
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ def read(fname):
test_requirements = req + dev_req

setup(
name="django-url-filter",
name="dj-url-filter",
version=__version__,
author=__author__,
description="Django URL Filter provides a safe way to filter data via human-friendly URLs.",
long_description="\n\n".join([readme, history, authors, licence]),
url="https://github.com/miki725/django-url-filter",
url="https://github.com/miki725/dj-url-filter",
license="MIT",
packages=find_packages(exclude=["test_project*", "tests*"]),
install_requires=requirements,
Expand All @@ -42,7 +42,6 @@ def read(fname):
"Natural Language :: English",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Development Status :: 2 - Pre-Alpha",
Expand Down
20 changes: 0 additions & 20 deletions test_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
"test_project.many_to_one",
"test_project.one_to_one",
"url_filter",
"debug_toolbar",
"debug_toolbar_alchemy",
"django_extensions",
"rest_framework",
"django.contrib.auth",
Expand All @@ -48,7 +46,6 @@

MIDDLEWARE = [
"test_project.middleware.SQLAlchemySessionMiddleware",
"debug_toolbar.middleware.DebugToolbarMiddleware",
]

TEMPLATES = [
Expand All @@ -61,20 +58,3 @@
"DEFAULT_FILTER_BACKENDS": ["url_filter.integrations.drf.DjangoFilterBackend"]
}

DEBUG_TOOLBAR_PANELS = [
"debug_toolbar.panels.versions.VersionsPanel",
"debug_toolbar.panels.timer.TimerPanel",
"debug_toolbar.panels.settings.SettingsPanel",
"debug_toolbar.panels.headers.HeadersPanel",
"debug_toolbar.panels.request.RequestPanel",
"debug_toolbar.panels.sql.SQLPanel",
"debug_toolbar_alchemy.panels.sql.SQLPanel",
"debug_toolbar.panels.staticfiles.StaticFilesPanel",
"debug_toolbar.panels.templates.TemplatesPanel",
"debug_toolbar.panels.cache.CachePanel",
"debug_toolbar.panels.signals.SignalsPanel",
"debug_toolbar.panels.logging.LoggingPanel",
"debug_toolbar.panels.redirects.RedirectsPanel",
]

DEBUG_TOOLBAR_CONFIG = {"ALCHEMY_DB_ALIASES": "test_project.middleware.dbs"}
4 changes: 0 additions & 4 deletions test_project/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals

import debug_toolbar
from django.conf import settings
from django.conf.urls import url
from django.urls import include
Expand Down Expand Up @@ -74,6 +73,3 @@

urlpatterns = router.urls


if settings.DEBUG:
urlpatterns += [url(r"^__debug__/", include(debug_toolbar.urls))]
34 changes: 20 additions & 14 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
[tox]
envlist =
{py27,py36,py37,py38,pypy,pypy3}-django{18,11}
{py36,py37,py38,pypy3}-django{20,latest}
py39-django{32,42,latest}
py310-django{32,42,latest}
py311-django{32,42,latest}
py312-django{32,42,latest}

[gh-actions]
python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312

[testenv]
basepython =
py27: python2.7
py36: python3.6
py37: python3.7
py38: python3.8
pypy: pypy
pypy3: pypy3
allowlist_externals = make
passenv = *
setenv =
PYTHONPATH = {toxinidir}
commands =
make install INSTALL_LOG=/dev/null
make clean-build clean-pyc clean-test test
deps =
django18: django<1.9
django18: djangorestframework<3.7
django18: django-debug-toolbar<1.10
django11: django<2
django20: django<2.1
django32: django<3.3
django32: djangorestframework<3.12
django32: SQLAlchemy<1.5
django42: django<4.2
django42: djangorestframework>3.12
django42: SQLAlchemy<1.5
djangolatest: django
djangolatest: SQLAlchemy<1.5
poetry_dep_groups = [dev]
whitelist_externals =
make

Expand Down
4 changes: 2 additions & 2 deletions url_filter/backends/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SQLAlchemyFilterBackend(BaseFilterBackend):
def __init__(self, *args, **kwargs):
super(SQLAlchemyFilterBackend, self).__init__(*args, **kwargs)

assert len(self.queryset._entities) == 1, (
assert self.queryset.is_single_entity, (
"{} does not support filtering when multiple entities "
"are being queried (e.g. session.query(Foo, Bar))."
"".format(self.__class__.__name__)
Expand All @@ -74,7 +74,7 @@ def get_model(self):
"""
Get the model from the given queryset
"""
return self.queryset._only_entity_zero().mapper.class_
return self.queryset._entity_from_pre_ent_zero().class_

def filter_by_specs(self, queryset):
"""
Expand Down
Loading