• Stars
    star
    821
  • Rank 55,122 (Top 2 %)
  • Language
    Python
  • License
    Other
  • Created almost 13 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

jQuery UI-powered auto-complete fields for ForeignKey, ManyToMany and text fields

Edit ForeignKey, ManyToManyField and CharField in Django Admin using jQuery UI AutoComplete

Build Status PyPI version

This Django app glues Django Admin, jQuery UI together to enable searching and managing ForeignKey and ManyToMany relationships.

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.

If you are building a new project then you should not use this.

Django has built in support now: https://docs.djangoproject.com/en/3.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.autocomplete_fields


selecting

selected

Documentation

http://django-ajax-selects.readthedocs.org/en/latest/

Installation

pip install django-ajax-selects

Add the app:

# settings.py
INSTALLED_APPS = (
    ...
    'ajax_select',  # <-   add the app
    ...
)

Include the urls in your project:

# urls.py
from django.urls import path
from django.conf.urls import include

from django.conf.urls.static import static
from django.contrib import admin
from django.conf import settings
from ajax_select import urls as ajax_select_urls

admin.autodiscover()

urlpatterns = [
    # This is the api endpoint that django-ajax-selects will call
    # to lookup your model ids by name
    path("admin/lookups/", include(ajax_select_urls)),
    path("admin/", admin.site.urls),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

Quick Usage

Define a lookup channel:

# yourapp/lookups.py
from ajax_select import register, LookupChannel
from .models import Tag

@register('tags')
class TagsLookup(LookupChannel):

    model = Tag

    def get_query(self, q, request):
        return self.model.objects.filter(name__icontains=q).order_by('name')[:50]

    def format_item_display(self, item):
        return u"<span class='tag'>%s</span>" % item.name

Add field to a form:

# yourapp/forms.py
from ajax_select.fields import AutoCompleteSelectMultipleField

class DocumentForm(ModelForm):

    class Meta:
        model = Document

    tags = AutoCompleteSelectMultipleField('tags')

This will now work in the Django Admin.

To use a form outside, be sure to include form.media on the template where you place the form:

{{ form.media }}
{{ form }}

Read the full documention here: outside of the admin

Fully customizable

  • Customize search query
  • Query other resources besides Django ORM
  • Format results with HTML
  • Customize styling
  • Customize security policy
  • Add additional custom UI alongside widget
  • Integrate with other UI elements elsewhere on the page using the javascript API
  • Works in Admin as well as in normal views

Assets included by default

https://jquery.com/ 3.7.1 https://jqueryui.com/ 1.13.2

Customize jquery

To use a custom jQuery UI theme you can set:

# settings.py
AJAX_SELECT_JQUERYUI_THEME = "/static/path-to-your-theme/jquery-ui-min.css"

https://jqueryui.com/themeroller/

If you need to use a different jQuery or jQuery UI then turn off the default assets:

# settings.py
AJAX_SELECT_BOOTSTRAP = False

and include jquery and jquery-ui yourself, making sure they are loaded before the Django admin loads.

Compatibility

  • Django >=3.2
  • Python >=3.10

Contributors

Many thanks to all contributors and pull requesters !

https://github.com/crucialfelix/django-ajax-selects/graphs/contributors/

License

Dual licensed under the MIT and GPL licenses:

More Repositories

1

supercolliderjs

The JavaScript client library for SuperCollider
TypeScript
471
star
2

atom-supercollider

SuperCollider development environment for Atom.io
CoffeeScript
84
star
3

supercolliderjs-examples

Example applications and code for supercollider.js
JavaScript
25
star
4

crucial-library

SuperCollider music programming library.
SuperCollider
18
star
5

API

simple Application Programming Interface framework for inter-application communication with SuperCollider
SuperCollider
17
star
6

dryadic

Dryadic is a micro-framework for managing trees of components across disparate rendering contexts.
TypeScript
11
star
7

supercolliderjs-browser

Tools for communicating between remote javascript clients (primarily web browsers) and supercollider.js
JavaScript
10
star
8

gulp-blog-scaffold

Template for gulp driven static site markdown+jade based blog
JavaScript
9
star
9

Mx

A scriptable mixer, data patching matrix and timeline for SuperCollider
SuperCollider
9
star
10

splines

Spline classes for SuperCollider
SuperCollider
8
star
11

supercollider-js-guide

Introduction to supercollider.js - the JavaScript client for SuperCollider
6
star
12

crucialviews

views, gadgets and widgets for supercollider
SuperCollider
4
star
13

ServerTools

Server and class introspection tools for SuperCollider
SuperCollider
3
star
14

cxaudio

Instr library and Pseudo-ugen classes
SuperCollider
3
star
15

generator-minimal-typescript

Yeoman generator to scaffold a minimal Typescript module
JavaScript
3
star
16

ZArchive

SuperCollider file archive : saves and reloads large datasets in a safe binary format
SuperCollider
3
star
17

CrucialTests

unit tests for various crucial related supercollider libraries
SuperCollider
2
star
18

repot-trilliontrees

This repository is a quick sketch using some new tech in order to try some things out and discover what works and what might be annoying and how to solve it. It isn't meant to be clean, it is meant to find and solve problems quickly. It's an experiment.
TypeScript
2
star
19

cxpatterns

Instr that create Patterns [supercollider]
SuperCollider
1
star
20

mxdevices

SuperCollider gadgets and musical devices
1
star
21

generator-custom-bootstrap

[0.0.0] Yeoman generator to install compass bootstrap with google webfonts, compass-recipes and live-reload
JavaScript
1
star
22

5easy

JavaScript
1
star