forked from alekam/django-tagging-autocomplete
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed README.txt in README.markdown Added more informations to README
- Loading branch information
nemesisdesign
committed
Feb 9, 2012
1 parent
f8c9a57
commit b75b259
Showing
40 changed files
with
89 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# django-tagging-autocomplete-tag-it | ||
|
||
Fork of *[django-tagging-autocomplete](http://code.google.com/p/django-tagging-autocomplete/)* that works with a modified version (another fork) jQuery UI Tag-it. | ||
|
||
**This is not stable**. If you would like to use this widget please share your ideas (and code) on how to improve it. | ||
|
||
## Demo: | ||
|
||
To see the jQuery UI widget in action its demos: [http://aehlke.github.com/tag-it/](http://aehlke.github.com/tag-it/) | ||
The forked repository for the javascript is: [https://github.com/nemesisdesign/tag-it](https://github.com/nemesisdesign/tag-it) | ||
|
||
## Features: | ||
* Tag editing | ||
* Autocompletition | ||
* Customizable minimum amount of letters before the autocompletition starts | ||
* Customizable maximum tags number | ||
* Costomizable max length of each tag | ||
* Aims to be flexible | ||
|
||
## Available settings: | ||
|
||
TAGGING_AUTOCOMPLETE_MIN_LENGTH defaults to 1 | ||
TAGGING_AUTOCOMPLETE_REMOVE_CONFIRMATION defaults to True | ||
TAGGING_AUTOCOMPLETE_ANIMATE defaults to True | ||
TAGGING_AUTOCOMPLETE_MAX_TAGS defaults to 20 - this general setting can be overriden in each field if needed | ||
TAGGING_AUTOCOMPLETE_JS_BASE_URL defaults to 'STATIC_URL/js/jquery-tag-it/' | ||
TAGGING_AUTOCOMPLETE_JQUERY_UI_FILE defaults to 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js' | ||
TAGGING_AUTOCOMPLETE_CSS is a list of CSS files and defaults to ['TAGGING_AUTOCOMPLETE_JS_BASE_URL/css/ui-autocomplete-tag-it.css'] | ||
|
||
## Usage | ||
|
||
I wrote these instructions quickly, don't trust this completely. | ||
|
||
###Usage in models: | ||
|
||
# models.py | ||
from django.db import models | ||
from tagging_autocomplete_tagit.models import TagAutocompleteTagItField | ||
|
||
class SomeModel(models.Model): | ||
# max_tags defaults to TAGGING_AUTOCOMPLETE_MAX_TAGS | ||
# If max_tags is specified it will override the value specified in TAGGING_AUTOCOMPLETE_MAX_TAGS | ||
tags = TagAutocompleteTagItField(max_tags=False) | ||
|
||
###Using the form widget: | ||
|
||
Alternatively you can use the TagAutocomplete form widget while creating your form. For example: | ||
|
||
# forms.py | ||
from django import forms | ||
from tagging.forms import TagField | ||
from tagging_autocomplete_tagit.widgets import TagAutocompleteTagIt | ||
|
||
class SomeForm(forms.Form): | ||
# max_tags defaults to TAGGING_AUTOCOMPLETE_MAX_TAGS | ||
# If max_tags is specified it will override the value specified in TAGGING_AUTOCOMPLETE_MAX_TAGS | ||
tags = TagField(widget=TagAutocompleteTagIt(max_tags=5)) | ||
|
||
##Instalation | ||
|
||
1. You need to have django-tagging already installed | ||
2. Download django-tagging-autocomplete-tag-it and use setup.py to install it on your system: | ||
python setup.py install | ||
(NOT SURE THIS WORKS NOW) | ||
4. Copy "jquery-tag-it" folder of this repository to the 'js' folder specified in your project's STATIC_URL setting. If you want to put it somewhere else add TAGGING_AUTOCOMPLETE_JS_BASE_URL to your project settings. | ||
5. Add "tagging_autocomplete_tagit" to installed apps in your project's settings. | ||
6. Add the following line to your project's urls.py file: | ||
|
||
(r'^tagging_autocomplete_tagit/', include('tagging_autocomplete_tagit.urls')), |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
14 changes: 7 additions & 7 deletions
14
tagging_autocomplete/models.py → tagging_autocomplete_tagit/models.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
from django.db import models | ||
from tagging.fields import TagField | ||
from tagging_autocomplete.widgets import TagAutocomplete | ||
from tagging_autocomplete_tagit.widgets import TagAutocompleteTagIt | ||
from django.contrib.admin.widgets import AdminTextInputWidget | ||
|
||
# The following code is based on models.py file from django-tinymce by Joost Cassee | ||
|
||
class TagAutocompleteField(TagField): | ||
class TagAutocompleteTagItField(TagField): | ||
""" | ||
TagField with autocomplete widget | ||
TagField with jQuery UI Tag-it widget | ||
""" | ||
|
||
def __init__(self, max_tags=False, *args, **kwargs): | ||
self.max_tags = max_tags | ||
super(TagAutocompleteField, self).__init__(*args, **kwargs) | ||
super(TagAutocompleteTagItField, self).__init__(*args, **kwargs) | ||
|
||
def formfield(self, **kwargs): | ||
defaults = {'widget': TagAutocomplete(max_tags=self.max_tags)} | ||
defaults = {'widget': TagAutocompleteTagIt(max_tags=self.max_tags)} | ||
defaults.update(kwargs) | ||
|
||
# As an ugly hack, we override the admin widget | ||
if defaults['widget'] == AdminTextInputWidget: | ||
defaults['widget'] = TagAutocomplete(max_tags=self.max_tags) | ||
defaults['widget'] = TagAutocompleteTagIt(max_tags=self.max_tags) | ||
|
||
return super(TagAutocompleteField, self).formfield(**defaults) | ||
return super(TagAutocompleteTagItField, self).formfield(**defaults) |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.conf.urls.defaults import * | ||
|
||
urlpatterns = patterns('tagging_autocomplete_tagit.views', | ||
url(r'^list$', 'list_tags', name='tagging_autocomplete_tagit-list'), | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters