Giter VIP home page Giter VIP logo

django-agnocomplete's Introduction

Django Agnostic Autocomplete

image

Heavily based on django-autocomplete-light v2 workflow and concepts, this toolkit offers a front-end agnostic way to get fields for autocompletion.

It will provide:

  • a simple and configurable entry-point management,
  • a REST-like HTTP API to search for results,
  • Fields and widgets that will make the interface between our Django code and your Javascript.

Status

Stable, used in production.

Install

$ pip install django-agnocomplete

Or add django-agnocomplete to your project requirements.

Documentation

The full documentation is browsable on Read the Docs

Tests

Install tox in your environment (it could be a virtualenv) and run:

$ tox

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

  • Python 3.6, 3.7, 3.8, 3.9.
  • Django 2.2.

and a flake8 check.

Are you a developer?

To target a specific test case, use the following:

$ tox -e py37-django22 --  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:

$ TOX_EXTRA=ipdb tox -e py36-django22

Note

We've got a self documented Makefile for common tasks, such as running the tests, building the docs, etc.

Run the demo

The (draft) demo site can be browsed using the Django devserver. Run:

$ make serve

It will run a syncdb (it may ask you questions) and then a runserver with your current demo.settings. You can browse the (very rough) website at http://127.0.0.1:8000/. You can add any runserver options you want using the tox positional parameters, like this:

$ tox -e serve -- 9090  # to change the listening port

Here you'll be able to see that django-agnocomplete has been easily and rapidly integrated with selectize.js, select2, jquery-autocomplete and typeahead. With the same backend, you can plug the JS front-end you want.

Troubles running the demo?

This demo project is not build as a production-ready application, models can change, but there's no migration in it. If you have database errors, you can try to remove it using:

$ make clean-db

Or, for more radical cleanup:

$ make clean-all

License

This piece of software is being published under the terms of the MIT License. Please read the LICENSE file for more details.

django-agnocomplete's People

Contributors

alyohea avatar brunobord avatar greatwizard avatar hobbestigrou avatar joehybird avatar jpic avatar mike-perdide avatar moumoutte avatar mrjmad avatar njoyard avatar nnachit avatar wo0dyn avatar yakuru avatar yohanboniface avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-agnocomplete's Issues

Deprecation by Django 1.9

Hey,

some deprecation while using django-agnocomplete==0.4.0

#####/agnocomplete/__init__.py:11: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
  from django.utils.importlib import import_module

Package description on PyPI

Should be loaded from README.rst.
Maybe it's time to switch from this setup.py to setup.cfg, it'll make things a bit easier, probably.

Page sizes

  • As a backend parameter, it has a minimum value, a max value and a default value.
  • page_size as a client argument: page_size argument to override the default. Although this argument can't be over limits.

Tweaks post 0.1.0

  • remove sqlite database, doc builds from the release package
  • add the "RTFD" build,
  • add build/ sdists/ directories to the .gitignore

Deprecation Warning for Django 1.9: request.REQUEST

RemovedInDjango19Warning: `request.REQUEST` is deprecated, use `request.GET` or `request.POST` instead.
  query = self.request.REQUEST.get('q', "")

gotta choose if we stick to the GET queries or if we want to handle both GET and POST queries.

Pagination

At the moment, we're only able to have the first page of suggestions. Good enough for the 0.1 release.

Eventually, we may want to jump to the next page, using a page argument.

  • I assume that nobody will ever want a "jump to the last page" feature. We hit the "next" page. If the resultset is empty, there won't be a jump to "next" button,
  • I assume that nobody will ever want a "jump to page 'n'" feature.
  • We definitely need to make it safe from a performance perspective, with a "don't use the offset" mechanism in mind (chunkator?)

So, how do we do that?

Default value(s)

Integrator should be able to provide a list of values to be proposed in the field values when the field is displayed. These are "non-selected" values, and ready-to-be-used without having to trigger an autocomplete query. Ex:

<select data-url="/somewhere/" data-query-size="3" name="friend_with">
   <option value="me">Me</option>
   <option value="everyone">Everyone</option>
</select>

Questions:

If the field has already a value:

  • are these default values retrieved and sent to the client, along with the selected value(s)?
  • if by default they're not sending these values, do we provide a custom flag to allow them to be sent anyway?

Support a "URL Proxy" agnocomplete

study the opportunity to simply have a "proxy" agnocomplete core object, one we could parametrize using a simple url argument. It would simply pass the q query to the target URL, retrieve its results (JSON) and re-build a "agnocomplete-compliant" resultset.

Idea:

  • take a chance to allow context-related arguments to be added to the URL argument,
  • the target URL argument could be a parameter: "query" or "search" instead of "q".

AgnocompleteModel.item not called for initial value

When overriding AgnocompleteModel.item to customize item display, initial value for AgnocompleteField is still displayed using the model's default string conversion method. AgnocompleteModel.item should also be called on it.

Demo to display error messages

Following #60 ; low priority, but it'd be nice to show errors when they happen in the demo. To give an example on how to handle them. Add it to the docs, also.

Cleanup pre-release branches

Let's discuss this:

  • there are several pre-release branches, carrying the RC tags,
  • some of these RC were not linearly stacked on each other, it may have happened that some commits that were on master were not on these RC (the error handling bit, for example),
  • as a consequence, one could think we may delete these branches, but on the other hand, deleting these branches means "deleting the tags".
  • on the other hand, these RCs were published on PyPI ; if somebody wants to browse the code, they can still download the tarball from PyPI.

multiple search terms

At the moment, it's an "OR", shall we provide a parameter to tell it's an and search?

Pass a callable in the URL configuration

to avoid the "deprecation warning":

 RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got demo.views.selectize_context_tag). Pass the callable instead.

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.