Login

Tag "ajax"

Snippet List

autocompleter with database query

This is an improvement of snippet 253 in that it supports database queries. Implementing autocompletion for foreign keys takes a few steps: 1) Put the snippet above into <app>/widgets/autocomplete.py. 2) Create a view of your foreign key model (here: Donator) in <app>/donator/views.py: from models import Donator from widgets.autocomplete import autocomplete_response def autocomplete(request): return autocomplete_response( request.REQUEST['text'], Donator, ( 'line_1', 'line_2', 'line_3', 'line_4', 'line_5', 'line_6', 'line_7', 'line_8', '^zip_code', 'location' ) ) This view returns the autocompletion result by searching the fields in the tuple. Each word from the form field must appear at least in one database field. 3) Create a URLconf that points to this new view. 4) In the form where you need the autocompletion, define the widget of the foreign key field as an instance of AutoCompleteField: from widget.autocomplete import AutoCompleteField field.widget = AutoCompleteField( url='/donator/autocomplete/'), options={'minChars': 3} ) The url parameter is the URL connected to the view in step 3), the options dict is passed on to the Ajax.Autocompleter JavaScript object. Links: * [Snippet 253](http://www.djangosnippets.org/snippets/253/) * [Django and scriptaculous integration](http://wiki.script.aculo.us/scriptaculous/show/IntegrationWithDjango) * [Ajax.Autocompleter](http://wiki.script.aculo.us/scriptaculous/show/Ajax.Autocompleter)

  • ajax
  • selection
  • database
  • autocomplete
  • query
  • foreign-key
  • prototype
  • scriptaculous
  • protoculous
Read More

Newforms Autocomplete Widget with Scriptaculous

From [here](http://gacha.id.lv/blog/26/01/2007/django-autocompletefield/) with litle improvements. [More about Script.aculo.us and Django](http://wiki.script.aculo.us/scriptaculous/show/IntegrationWithDjango)

  • ajax
  • newforms
  • autocomplete
Read More

jquery autocomplete widget

newforms widget for autocompleting text fields using jquery autocomplete plugin: http://jquery.bassistance.de/autocomplete/ to be implemented: - store the pk value into an hidden field - handling ChoiceFields and many others massimo dot scamarcia at gmail.com

  • ajax
  • newforms
  • javascript
  • forms
  • jquery
  • widgets
Read More
Author: skam
  • 25
  • 145

JsonResponse

A subclass of `HttpResponse` useful as a shortcut in views; it chooses the correct JSON serializer based on whether or not it is passed a QuerySet.

  • ajax
  • serialize
  • json
Read More
Author: zakj
  • 24
  • 85

jQuery ajax search

This is the result of my first tests with jQuery and Django. After entering a search term it gets search results using ajax and json. Then is uses the rather crude `result_table` function to generate a table of results. Django is on the serverside for generating json

  • ajax
  • jquery
Read More

ajax protocol for data

Can be used for create a json format response data. Just like: {response:'ok', next:'nexturl', message:'response message', data:'returned data'} for success. {response:'fail', next:'nexturl', message:'response message', error:'error messages'} for failure. And there are some dump function: json - dump a python variable into json format string json_response - dump a python variable into json format string, and then use it create a HttpResponse object.

  • ajax
  • serialize
Read More

51 snippets posted so far.