Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Autocomplete for comma-separated CharField? #32

Closed
gw0 opened this Issue Aug 5, 2012 · 9 comments

Comments

Projects
None yet
2 participants

gw0 commented Aug 5, 2012

I was wondering if it supports autocomplete on a comma separated special CharField? More precisely if it can be used with an app for tagging objects, like django-cms-pagetags (plugin for Django CMS) that uses django-tagging for backend and jQuery UI Autocomplete through a widget for entering a comma-separated list of tags for a specific page.

Owner

jpic commented Aug 5, 2012

There is no jQuery UI support, but you can find other autocomplete apps that support it on djangopackages.com. There is also no CharField autocomplete yet.

However, this app can make an autocomplete like StackOverflow's tag field. it is possible with django-generic-m2m, you can see this example in the test project.

Owner

jpic commented Aug 20, 2012

Can you show live examples of how this would work ? Thanks !

gw0 commented Aug 20, 2012

Yes, I had in mind something similar to StackOverflow's tag field, that is also similar to how jQuery UI Autocomplete can handle multiple values.

As an example Django app that is using this I mentioned django-cms-pagetags plugin that allows you to add tags to Django CMS pages, but its autocompletion code is a little old and would need some cleaning up...

Owner

jpic commented Aug 21, 2012

I implemented a proof of concept. If it works for you i'll wrap it up for release.

Run test_project: https://github.com/yourlabs/django-autocomplete-light/tree/master/test_project
Visit: http://localhost:8000/admin/charfield_autocomplete/address/

Here are the choices for this example app: https://github.com/yourlabs/django-autocomplete-light/blob/master/test_project/charfield_autocomplete/autocomplete_light_registry.py

Let me know if that works for you. Thank you for your feedback.

gw0 commented Aug 21, 2012

Nice, but available tags should not be limited by a choice field. If someone enters a new value it should be added to available choices. Maybe the jQuery UI example was misleading about that, sorry...

For dealing with converting input text to tags and back there are already backend apps that should be reused, because they are pretty stable, simple to use and a lot of people are already using them - check out (django-tagging-ng)[https://github.com/svetlyak40wt/django-tagging-ng] and (django-taggit)[https://github.com/alex/django-taggit](both also have documentation on Readthedocs).

Anyway, I am switching to another CMS (Mezzanine) that doesn't have any tag/autocompletion issues, so I probably won't integrate django-autocomplete-light into django-cms-pagetags what was my initial plan.

Owner

jpic commented Aug 21, 2012

Nice, but available tags should not be limited by a choice field. If someone enters a new value it should be added to available choices. Maybe the jQuery UI example was misleading about that, sorry...

For dealing with converting input text to tags and back there are already backend apps that should be reused, because they are pretty stable, simple to use and a lot of people are already using them - check out (django-tagging-ng)[https://github.com/svetlyak40wt/django-tagging-ng] and (django-taggit)https://github.com/alex/django-taggit.

Actually, that works because you can still save the CharField with values that aren't in choices, for example: "Paris, Madrid, test" just worked for me. Correct me if I'm wrong, but that should automatically create the "test" tag model, which would become available in the autocomplete. I'm going to double check that by adding one of these apps in this example.

Anyway, I am switching to another CMS (Mezzanine) that doesn't have any tag/autocompletion issues, so I probably won't integrate django-autocomplete-light into django-cms-pagetags what was my initial plan.

Personally, I would do the CMS from existing apps, rather than try to reuse an existing project. This seems more flexible and reduces the chances that "something" gets in the way.

Owner

jpic commented Aug 21, 2012

Confirmed in 5b94e0f95dfbb, the only issue i find is that django-tagging-ng strips commas in the tag field sometimes. This does not happen with django-taggin.

gw0 commented Aug 21, 2012

Yes, that's why I added the FORCE_TAG_DELIMITER to django-tagging-ng, because else it strips commas if you use tags without spaces.

@jpic jpic closed this Aug 22, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment