Add basic import/export support for tags

This commit is contained in:
Christopher C. Wells 2022-04-04 15:44:26 -07:00 committed by Christopher Charbonneau Wells
parent 7804fe8f2d
commit bdc28991cb
1 changed files with 7 additions and 1 deletions

View File

@ -184,11 +184,17 @@ class TaggedItemInline(admin.StackedInline):
model = models.Tagged model = models.Tagged
class TagImportExportResource(ImportExportResourceBase):
class Meta:
model = models.Tag
@admin.register(models.Tag) @admin.register(models.Tag)
class TagAdmin(admin.ModelAdmin): class TagAdmin(ImportExportMixin, ExportActionMixin, admin.ModelAdmin):
form = TagAdminForm form = TagAdminForm
inlines = [TaggedItemInline] inlines = [TaggedItemInline]
list_display = ["name", "slug", "color", "last_used"] list_display = ["name", "slug", "color", "last_used"]
ordering = ["name", "slug"] ordering = ["name", "slug"]
search_fields = ["name"] search_fields = ["name"]
prepopulated_fields = {"slug": ["name"]} prepopulated_fields = {"slug": ["name"]}
resource_class = TagImportExportResource