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

Supports Django 4.2 #136

Closed
wants to merge 4 commits into from
Closed
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
32 changes: 14 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ jobs:
matrix:
include:

- name: Python 3.9 / Django 2.2
python_version: "3.9"
tox_env: py39-django22

- name: Python 3.9 / Django 3.0
python_version: "3.9"
tox_env: py39-django30

- name: Python 3.9 / Django 3.1
python_version: "3.9"
tox_env: py39-django31

- name: Python 3.7 / Django 3.2
python_version: "3.7"
tox_env: py37-django32

- name: Python 3.8 / Django 3.2
python_version: "3.8"
tox_env: py38-django32
Expand All @@ -43,9 +27,21 @@ jobs:
python_version: "3.10"
tox_env: py310-django32

- name: Python 3.9 / Django 4.0
- name: Python 3.8 / Django 4.2
python_version: "3.8"
tox_env: py38-django42

- name: Python 3.9 / Django 4.2
python_version: "3.9"
tox_env: py39-django40
tox_env: py39-django42

- name: Python 3.10 / Django 4.2
python_version: "3.10"
tox_env: py310-django42

- name: Python 3.11 / Django 4.2
python_version: "3.11"
tox_env: py311-django42

- name: DocLint
python_version: "3.10"
Expand Down
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Django Agnostic Autocomplete
============================


.. image:: https://travis-ci.org/peopledoc/django-agnocomplete.svg?branch=master
:target: https://travis-ci.org/peopledoc/django-agnocomplete
.. image:: https://github.com/peopledoc/django-agnocomplete/actions/workflows/ci.yml/badge.svg
:target: https://github.com/peopledoc/django-agnocomplete/actions/workflows/ci.yml


Heavily based on `django-autocomplete-light v2 <https://github.com/yourlabs/django-autocomplete-light/>`_ workflow and concepts, this toolkit offers a front-end agnostic way to get fields for autocompletion.
Expand Down Expand Up @@ -46,8 +46,8 @@ Install ``tox`` in your environment (it could be a virtualenv) and run:

It'll run the tests for all the combinations of the following:

* Python 3.6, 3.7, 3.8, 3.9.
* Django 2.2.
* Python 3.8, 3.9, 3.10
* Django 3.2, 4.2

and a ``flake8`` check.

Expand All @@ -58,15 +58,15 @@ To target a specific test case, use the following:

.. code:: sh

$ tox -e py37-django22 -- demo.tests.test_core.AutocompleteChoicesPagesOverrideTest
$ tox -e py38-django32 -- demo.tests.test_core.AutocompleteChoicesPagesOverrideTest

Everything after the double-dash will be passed to the django-admin.py test command.

If you need to install a debugger (let's say `ipdb`), you can use the ``TOX_EXTRA`` environment variable like this:

.. code:: sh

$ TOX_EXTRA=ipdb tox -e py36-django22
$ TOX_EXTRA=ipdb tox -e py38-django32

.. note::

Expand Down
5 changes: 0 additions & 5 deletions agnocomplete/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""
import logging

import django
from django.conf import settings
from django.utils.module_loading import autodiscover_modules

Expand All @@ -24,7 +23,3 @@ def get_namespace():
def autodiscover():
"""Auto-discover INSTALLED_APPS agnocomplete modules."""
autodiscover_modules('autocomplete')


if django.VERSION[:2] < (3, 2):
default_app_config = 'agnocomplete.apps.AgnocompleteConfig'
4 changes: 2 additions & 2 deletions agnocomplete/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def classproperty(func):

e.g::

class SafeClass(object):
class SafeClass:

@classproperty
def safe(cls):
return True

class UnsafeClass(object):
class UnsafeClass:

@classproperty
def safe(cls):
Expand Down
18 changes: 6 additions & 12 deletions demo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ class Person(models.Model):
email = models.EmailField(max_length=100)
location = models.CharField(max_length=100)

def __unicode__(self):
def __str__(self):
return " ".join((self.first_name, self.last_name))
__str__ = __unicode__

@property
def is_active(self):
Expand All @@ -36,50 +35,45 @@ class FavoriteColor(models.Model):
person = models.ForeignKey(Person, on_delete=models.CASCADE)
color = models.CharField(max_length=100, choices=COLORS)

def __unicode__(self):
def __str__(self):
return "{}'s favorite color is {}".format(self.person, self.color)
__str__ = __unicode__


class Tag(models.Model):
name = models.CharField(max_length=50)

def __unicode__(self):
def __str__(self):
return self.name
__str__ = __unicode__


class PersonTag(models.Model):
person = models.ForeignKey(Person, on_delete=models.CASCADE)
tags = models.ManyToManyField(Tag)

def __unicode__(self):
def __str__(self):
return "{} is tagged: {}".format(
self.person,
", ".join([force_str(t) for t in self.tags.all()]) or "Nothing"
)
__str__ = __unicode__


class ContextTag(models.Model):
name = models.CharField(max_length=50)
domain = models.CharField(max_length=100)

def __unicode__(self):
def __str__(self):
return "[{}] {}".format(
self.domain,
self.name
)
__str__ = __unicode__


class PersonContextTag(models.Model):
person = models.ForeignKey(Person, on_delete=models.CASCADE)
tags = models.ManyToManyField(ContextTag)

def __unicode__(self):
def __str__(self):
return "{} is tagged: {}".format(
self.person,
", ".join([force_str(t) for t in self.tags.all()]) or "Nothing"
)
__str__ = __unicode__
4 changes: 2 additions & 2 deletions docs/autocomplete-definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Your front-end code may send you extra arguments that are not covered by the sta
extra = kwargs.get('extra_suff', None)
if extra_stuff:
change_something_in_the_search_method(extra_stuff)
return super(AutocompleteColorExtra, self).items(query, **kwargs)
return super().items(query, **kwargs)

You can also override the :meth:`get_extra_arguments()` method **in your views** to eventually filter or manipulate these extra arguments. By default, :meth:`get_extra_arguments()` grabs arguments from the GET parameters that are not the `query` value.

Expand All @@ -258,7 +258,7 @@ You can also override the :meth:`get_extra_arguments()` method **in your views**
form = SearchFormExtra

def get_extra_arguments(self):
extras = super(SelectizeExtraView, self).get_extra_arguments()
extras = super().get_extra_arguments()
whitelist = ['foo', 'bar']
extras = filter(lambda x: x[0] in whitelist, extras)
return dict(extras)
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
2 changes: 1 addition & 1 deletion docs/fields-widgets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ We're half way here: the view needs to know that, when the form & fields will be

@method_decorator(allow_create)
def form_valid(self, form):
return super(PersonTagModelViewWithCreate, self).form_valid(form)
return super().form_valid(form)

.. important::

Expand Down
3 changes: 1 addition & 2 deletions docs/url-proxy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ The :meth:`get_http_call_kwargs()` method is completely overridable like this:
search_url = 'http://api.example.com/search'

def get_http_call_kwargs(self, query, **kwargs):
query_args = super(
AutocompleteUrlExtraArgs, self).get_http_call_kwargs(query)
query_args = super().get_http_call_kwargs(query)
query_args['auth_token'] = 'GOODAUTHTOKEN'
return query_args

Expand Down
11 changes: 3 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@ classifiers =
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Framework :: Django :: 2.2
Framework :: Django :: 3.0
Framework :: Django :: 3.1
Programming Language :: Python :: 3.11
Framework :: Django :: 3.2
Framework :: Django :: 4.0
Framework :: Django :: 4.2
Topic :: Internet :: WWW/HTTP
Topic :: Internet :: WWW/HTTP :: Dynamic Content

Expand Down Expand Up @@ -52,8 +49,6 @@ addopts =
testpaths =
demo/tests/
filterwarnings =
error
# Ignoring for now: RemovedInDjango50Warning
ignore:.*The USE_L10N setting is deprecated.*
default

DJANGO_SETTINGS_MODULE = demo.settings
17 changes: 7 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[tox]
envlist =
py39-django{22,30,31,40}
py{37,38,39,310}-django32,
py{38,39,310}-django32
py{38,39,310,311}-django42
flake8,doclint

[testenv]
usedevelop = True
pip_pre = False
extras = dev
setenv =
PYTHONPATH = {toxinidir}
basepython =
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10
Expand All @@ -20,12 +21,8 @@ deps =
{env:TOX_EXTRA:}
coverage
-rrequirements-test.pip
# Keeping it here, because we'll probably widen our Django version tests.
django22: Django==2.2.*
django30: Django==3.0.*
django31: Django==3.1.*
django32: Django==3.2.*
django40: Django==4.0.*
django42: Django==4.2.*
serve: Django
commands =
pytest {posargs}
Expand All @@ -43,7 +40,7 @@ skip_install = True
usedevelop = False
changedir = docs/
deps = Sphinx
whitelist_externals = make
allowlist_externals = make
commands =
make clean html SPHINXOPTS='-W'
python doc_checker.py
Expand All @@ -60,6 +57,6 @@ commands =
[testenv:docs]
changedir = docs/
deps = Sphinx
whitelist_externals = make
allowlist_externals = make
commands =
make html
Loading