In a Django project i installed the django_taggit extension. It integrates well with the Django admin interface. I have two problems though:
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?
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?
Make your own admin class for tags (inherit it of taggit's admin), then use:
admin.site.unregister(Tag)
admin.site.register(Tag, YourTagClass)