Convert django model choice fields into typeahead fields.
Project description
# Django Bootstrap Typeahead
## Convert django model choice fields into typeahead fields.
Typeahead inputs built ontop of [Django](https://www.djangoproject.com/) and [Bootstrap](http://getbootstrap.com/).
![Example](http://thegoods.aj7may.com/content/images/2014/Feb/Screen_Shot_2014_02_05_at_5_27_56_PM.png)
### Install:
`> pip install django-bootstrap-typeahead`
### Usage:
* Add `django-bootstrap-typeahead` to the installed apps of your Django Project
* create a form and use `TypeaheadField` instead of `ModelChoiceField`
or `MultipleTypeaheadField` instead of `ModelMultipleChoiceField`
* Be sure to include the form's required media in the template. _ie._ `{{ form.media }}`
* Also be sure to include [Twitter Bootstrap](http://getbootstrap.com/)
### Example:
_forms.py_
from django import forms
from django_bootstrap_typeahead.fields import *
from .models import Thing
def build_thing(value):
thing, created = Thing.objects.get_or_create(name=value)
return thing
class TestForm(forms.Form):
typeahead = TypeaheadField(
queryset=Thing.objects.all(),
builder=build_thing
)
multi_typeahead = MultipleTypeaheadField(
queryset=Thing.objects.all(),
builder=build_thing
)
## Convert django model choice fields into typeahead fields.
Typeahead inputs built ontop of [Django](https://www.djangoproject.com/) and [Bootstrap](http://getbootstrap.com/).
![Example](http://thegoods.aj7may.com/content/images/2014/Feb/Screen_Shot_2014_02_05_at_5_27_56_PM.png)
### Install:
`> pip install django-bootstrap-typeahead`
### Usage:
* Add `django-bootstrap-typeahead` to the installed apps of your Django Project
* create a form and use `TypeaheadField` instead of `ModelChoiceField`
or `MultipleTypeaheadField` instead of `ModelMultipleChoiceField`
* Be sure to include the form's required media in the template. _ie._ `{{ form.media }}`
* Also be sure to include [Twitter Bootstrap](http://getbootstrap.com/)
### Example:
_forms.py_
from django import forms
from django_bootstrap_typeahead.fields import *
from .models import Thing
def build_thing(value):
thing, created = Thing.objects.get_or_create(name=value)
return thing
class TestForm(forms.Form):
typeahead = TypeaheadField(
queryset=Thing.objects.all(),
builder=build_thing
)
multi_typeahead = MultipleTypeaheadField(
queryset=Thing.objects.all(),
builder=build_thing
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-bootstrap-typeahead-1.1.5.tar.gz
.
File metadata
- Download URL: django-bootstrap-typeahead-1.1.5.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dc8d58ed53f1946834606bdeca3104097a7aa34f3b706b3e255910b41a4c851 |
|
MD5 | d87caae403754498a1e5eef5933156a5 |
|
BLAKE2b-256 | 5d0a9923eeac8153a550b01c162a91720f07a9cfe2aad5b49c6010778244b9a4 |