Giter VIP home page Giter VIP logo

prakhar-goel / django-admin-autocomplete-all Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pyutil/django-admin-autocomplete-all

0.0 1.0 0.0 38 KB

Django admin: Use select2 (autocomplete_fields) everywhere. Implicit is better than explicit. Because it is brief and easy. Plus: gives better context if you try filter the content in autocomplete fields.

License: MIT License

Makefile 15.71% Python 51.69% JavaScript 32.59%

django-admin-autocomplete-all's Introduction

django-admin-autocomplete-all

Django admin: Use select2 (autocomplete_fields) everywhere. Implicit is better than explicit. Because it is brief and easy. In addition gives improved context in get_search_results so you can apply filters based on current and form values. Install Install the last stable release django-admin-autocomplete-all Add into INSTALLED_APPS: 'autocomplete_all', Usage (more context for server-side filters) Read in our Documentation (readthedocs) or in autocomplete_all/js/autocomplete_params.js. Usage (add all foreign keys to autocomplete_fields) In your admin.py import ModelAdmin, StackedInline and/or TabularInline 'from autocomplete_all' instead of 'from admin'. import autocomplete_all class MyModelAdmin(autocomplete_all.ModelAdmin): # .... In such ModelAdmin class no other settings are required, but you can: autocomplete_except = [<field1>, ..] # disable adding autocomplete_fields for listed fields autocomplete_all = False # disable automatic adding of autocomplete_fields at all At the first start you will probably receive a lot of django errors/warnings. They mean that you don't have registered the related ModelAdmin classes or that such class lacks search_fields=.. To solve these messages you can register the required ModelAdmin classes (make sure they have search_fields=..). See ModelAdmin.autocomplete_fields in Django docs for details. Alternatively you can disable the functionality in particular case using autocomplete_exclude=[..]. This is useful if you have models not fully used yet (ie. empty) and you want prevent them to be accessible in admin interface. Example: In the application models you have ForeignKey(s) related into User model (outside of this application). To avoid error messages while starting your Django project add: from django.contrib.auth.models import User from django.contrib.auth.admin import UserAdmin # must define search_fields=.. (which is true in this case) admin.site.register(User, UserAdmin)

django-admin-autocomplete-all's People

Contributors

pyutil avatar zvolsky avatar

Watchers

 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.