Giter Site home page Giter Site logo

abdennour001 / django-ajax-selects Goto Github PK

View Code? Open in Web Editor NEW

This project forked from crucialfelix/django-ajax-selects

0.0 1.0 0.0 626 KB

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

License: Other

Python 85.41% CSS 1.17% JavaScript 8.47% HTML 2.32% Makefile 1.51% Shell 1.12%

django-ajax-selects's Introduction

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

Build Status PyPI version


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.conf.urls import url, 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 = [

    # place it at whatever base url you like
    url(r'^ajax_select/', include(ajax_select_urls)),

    url(r'^admin/', include(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

  • //ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'
  • //code.jquery.com/ui/1.12.1/jquery-ui.js
  • //code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css

Compatibility

  • Django >=2.2
  • Python >=3.6

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:

django-ajax-selects's People

Contributors

crucialfelix avatar sjrd avatar morr0350 avatar jmerdich avatar cabalist avatar theunraveler avatar artscoop avatar buriy avatar sebslomski avatar zvolsky avatar gertingold avatar jmfederico avatar sourcefilter avatar squidsoup avatar leogout avatar mzdeb avatar madison-ookla avatar nwp90 avatar onyekaa avatar jellonek avatar rlskoeser avatar skrzypek avatar teelee7133 avatar tlangens avatar xbello avatar zablotski avatar hwkns avatar karlmoritz avatar joshblum avatar jimmy0017 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.