Thursday, March 28, 2013

re: Displaying And Selecting Tags in Admin Site

Hi All

New to Django and coding in general, so sorry if this has been covered - I did search the group postings, have read the documentation, trawled the net etc, but couldn't find anything directly relevant

I have been following various tutorials (django homepage, youtube etc) for how to start creating a blog site

What I would like to do seems really simple, but I cannot find a solution

Django 1.5 on Ubuntu Server 12.04LTS

It uses Taggable Manager, so in models.py we see

#models.py

from taggit.managers import TaggableManager

class Post(models.Model):
    title = models.CharField(max_length=100)
    ....
    tags = TaggableManager()

#admin.py

from blog.models import Post

class PostAdmin(admin.ModelAdmin):
    fieldsets = [
        ('Title',      {'fields': ['title']}),
        ......
        ('Tags',     {'fields': ['tags'], 'classes': ['collapse']}),
    ]

admin.site.register(Post, PostAdmin)

____

This works fine

What I would like to do is change the way that tags can be viewed and selected in the admin site

Currently, it is as a comma separated list

I would like to pre-create the tags, then see them in a drop down, or table, or similar, so that one or more may be selected
The view I am looking to achieve would be as if 'filter_horizontal = ['tags']' had been applied

However, I cannot find a way to do it

I have tried to give the tags a separate class, with a ManyToManyField link into Post, but any tags that are created are not displayed - and this is probably really not the right approach

So is it possible to change the way that tags from TaggableManager is displayed? Can it be as a selection box, or check boxes or anything else? Or are we stuck with the list approach?

Any advice would be gratefully received

Many Thanks

Jon

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment