dlamotte / django-tagging

Automatically exported from code.google.com/p/django-tagging
Other
0 stars 0 forks source link

TagSelectField (using FilteredSelectMultiple) #189

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
A variation of the django-tagging TagField which uses a 
SelectMultiple widget instead of free text field. (Actually, it uses
admin's FilterSelectMultiple).

class MyModel(models.Model):
    ...
    tags = TagSelectField(filter_horizontal=True, blank=False)

Sometimes we only want users to select from existing tags, rather than
create new ones on the fly. But at the same time we want all the
django-tagging features (multiple content types, the funky managers, etc),
so don't want to go back to a plain old ManyToMany.

Ideally, this and TagField shouldn't really need a database column. But it
seems Django's model fields must either be a 'field', which needs a
database field; or a 'many to many', which needs a related table. Patching
a many to many field works for instance add/update but the instance delete
method is hard coded to expect the related table.

I think this might be worth including in tagging.fields.

Original issue reported on code.google.com by litchfie...@gmail.com on 12 Mar 2009 at 1:18

Attachments:

GoogleCodeExporter commented 8 years ago
very cool feature, should be included

Original comment by ammac...@gmail.com on 15 Oct 2009 at 4:53

GoogleCodeExporter commented 8 years ago
I agree. We don't expect to allow user tagging on our site (not a blog), but 
entries
tagged by us would be very useful. And FilterSelectMultiple is the proper 
interface
for that. 

Original comment by tereza.s...@gmail.com on 15 Oct 2009 at 5:01

GoogleCodeExporter commented 8 years ago
litchfield4:
i modified your TagSelectField to allow for filtered choices. if 'choices' is 
passed as a keyword 2 tuple, only a 
subset of tags are displayed/chosen.

however this has a problem: forms in the admin generated from model fields work 
as expected, but the same 
syntax in admin forms in admin.py throws an error or is ignored. :(

Original comment by ammac...@gmail.com on 22 Oct 2009 at 6:52

Attachments:

GoogleCodeExporter commented 8 years ago
this needs to be added to the project ASAP, it's a great feature and it really 
puzzled 
me that this wasn't the default approach for tagging when i first installed 
django-
tagging.

major thanks

Original comment by andrete...@gmail.com on 17 Nov 2009 at 5:30

GoogleCodeExporter commented 8 years ago
i made a hacky kind of workaround: 
http://bitbucket.org/tehfink/django-taggroups/

Original comment by ammac...@gmail.com on 17 Nov 2009 at 6:28