Skip to content

Commit fe6cc15

Browse files
authored
Merge pull request #303 from crucialfelix/feature/fixes-and-updates
feature/fixes and updates
2 parents 9bf8df4 + b48c8ae commit fe6cc15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+35131
-574
lines changed

.github/workflows/tests.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ name: Tests
66
on:
77
# Triggers the workflow on push or pull request events but only for the develop branch
88
push:
9-
branches: [ develop ]
9+
branches: [develop]
1010
pull_request:
11-
branches: [ develop ]
11+
branches: [develop]
1212

1313
# Allows you to run this workflow manually from the Actions tab
1414
workflow_dispatch:
@@ -22,18 +22,21 @@ jobs:
2222

2323
strategy:
2424
matrix:
25-
python-version: ['3.8', '3.9', '3.10']
25+
python-version: ["3.10", "3.11", "3.12"]
2626

2727
# Steps represent a sequence of tasks that will be executed as part of the job
2828
steps:
29-
- uses: actions/checkout@v1
30-
- name: Set up Python ${{ matrix.python-version }}
31-
uses: actions/setup-python@v2
32-
with:
33-
python-version: ${{ matrix.python-version }}
34-
- name: Install dependencies
35-
run: |
36-
python -m pip install --upgrade pip
37-
python -m pip install tox tox-gh-actions
38-
- name: Test with tox
39-
run: tox
29+
- uses: actions/checkout@v3
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
- name: Check with ruff
35+
uses: jpetrucciani/ruff-check@main
36+
with:
37+
path: "ajax_select"
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install ruff tox tox-gh-actions
41+
- name: Test with tox
42+
run: tox

Makefile

Lines changed: 0 additions & 44 deletions
This file was deleted.

README.md

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
[![Build Status](https://travis-ci.org/crucialfelix/django-ajax-selects.svg?branch=master)](https://travis-ci.org/crucialfelix/django-ajax-selects) [![PyPI version](https://badge.fury.io/py/django-ajax-selects.svg)](https://badge.fury.io/py/django-ajax-selects)
44

5+
This Django app glues Django Admin, jQuery UI together to enable searching and managing ForeignKey and ManyToMany relationships.
6+
7+
At the time it was created Django did not have any way to do this, and this solution glued together some technologies of the day.
8+
9+
If you are building a new project then you should not use this.
10+
11+
Django has built in support now:
12+
https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.autocomplete_fields
13+
14+
515
---
616

717
![selecting](/docs/source/_static/kiss.png?raw=true)
@@ -31,7 +41,9 @@ Include the urls in your project:
3141

3242
```py
3343
# urls.py
34-
from django.conf.urls import url, include
44+
from django.urls import path
45+
from django.conf.urls import include
46+
3547
from django.conf.urls.static import static
3648
from django.contrib import admin
3749
from django.conf import settings
@@ -40,11 +52,10 @@ from ajax_select import urls as ajax_select_urls
4052
admin.autodiscover()
4153

4254
urlpatterns = [
43-
44-
# place it at whatever base url you like
45-
url(r'^ajax_select/', include(ajax_select_urls)),
46-
47-
url(r'^admin/', include(admin.site.urls)),
55+
# This is the api endpoint that django-ajax-selects will call
56+
# to lookup your model ids by name
57+
path("admin/lookups/", include(ajax_select_urls)),
58+
path("admin/", admin.site.urls),
4859
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
4960
```
5061

@@ -107,14 +118,34 @@ Read the full documention here: [outside of the admin](http://django-ajax-select
107118

108119
## Assets included by default
109120

110-
* //ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'
111-
* //code.jquery.com/ui/1.12.1/jquery-ui.js
112-
* //code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css
121+
https://jquery.com/ 3.7.1
122+
https://jqueryui.com/ 1.13.2
123+
124+
## Customize jquery
125+
126+
To use a custom jQuery UI theme you can set:
127+
128+
```python
129+
# settings.py
130+
AJAX_SELECT_JQUERYUI_THEME = "/static/path-to-your-theme/jquery-ui-min.css"
131+
```
132+
133+
https://jqueryui.com/themeroller/
134+
135+
If you need to use a different jQuery or jQuery UI then turn off the default assets:
136+
137+
```python
138+
# settings.py
139+
AJAX_SELECT_BOOTSTRAP = False
140+
```
141+
142+
and include jquery and jquery-ui yourself, making sure they are loaded before the Django admin loads.
143+
113144

114145
## Compatibility
115146

116-
* Django >=2.2
117-
* Python >=3.6
147+
* Django >=3.2
148+
* Python >=3.10
118149

119150
## Contributors
120151

ajax_select/admin.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
class AjaxSelectAdmin(admin.ModelAdmin):
7-
""" in order to get + popup functions subclass this or do the same hook inside of your get_form """
7+
"""in order to get + popup functions subclass this or do the same hook inside of your get_form"""
88

99
def get_form(self, request, obj=None, **kwargs):
1010
form = super().get_form(request, obj, **kwargs)
@@ -14,16 +14,19 @@ def get_form(self, request, obj=None, **kwargs):
1414

1515

1616
class AjaxSelectAdminInlineFormsetMixin:
17-
1817
def get_formset(self, request, obj=None, **kwargs):
1918
fs = super().get_formset(request, obj, **kwargs)
2019
autoselect_fields_check_can_add(fs.form, self.model, request.user)
2120
return fs
2221

2322

24-
class AjaxSelectAdminTabularInline(AjaxSelectAdminInlineFormsetMixin, admin.TabularInline):
23+
class AjaxSelectAdminTabularInline(
24+
AjaxSelectAdminInlineFormsetMixin, admin.TabularInline
25+
):
2526
pass
2627

2728

28-
class AjaxSelectAdminStackedInline(AjaxSelectAdminInlineFormsetMixin, admin.StackedInline):
29+
class AjaxSelectAdminStackedInline(
30+
AjaxSelectAdminInlineFormsetMixin, admin.StackedInline
31+
):
2932
pass

0 commit comments

Comments
 (0)