0

In a Django project i installed the django_taggit extension. It integrates well with the Django admin interface. I have two problems though:

Problem A: flatchoices

I cannot show a comma-seperated tag list in the list view of my taggable model. Meaning:

# models.py
class Topic(models.Model):
    name = models.CharField(max_length=100)
    tags = TaggableManager(blank=True)

# admin.py
class TopicAdmin(admin.ModelAdmin):
    list_display = ('name', 'tags')

admin.site.register(Topic, TopicAdmin)

Throws an error:

AttributeError: 'TaggableManager' object has no attribute 'flatchoices'

Question: How can i add the functionality i need without changing the extension sources so that i am still able to do updates?

Problem B: prepopulated_fields

If i navigate to the "Add Tag" admin view i can add new tags (naturally). There are two mandatory fields: name and slug.

I want the slug to be prepoluated via prepopulated_fields = {"slug": ("name",)}, so that i do not have to type in the slug manually.

Question: How can i add the prepopulated_fields property?

Alp
  • 29,274
  • 27
  • 120
  • 198

1 Answers1

1
  1. Use official docs wisely
  2. Make your own admin class for tags (inherit it of taggit's admin), then use:

    admin.site.unregister(Tag)
    admin.site.register(Tag, YourTagClass)
    
ilvar
  • 5,718
  • 1
  • 20
  • 17
  • looks like i don't need taggit at all, and should code my own tagging app from the scratch – Alp May 11 '12 at 07:34
  • It depends. If you need only small piece of the functionality - maybe, yes. But if you need also tag clouds, and all stuff, and all other stuff (or probably will need it need in the future) then you'd better improve 3rd party library. – ilvar May 11 '12 at 19:45