1π
β
For starters, get rid of albums_(). That method makes little-to-no-sense in its current implementation. Then change ImageAdmin accordingly:
class ImageAdmin(admin.ModelAdmin):
search_fields = ["title"]
# Don't call albums_(). Aside from the fact that it doesn't do what you want it to do,
# The functionality you're looking for is already provided by Django:
list_display = ["title", "tags_", "albums", "created"]
list_filter = ["tags", "albums"]
When you create a foreignkey the way you have, there will only be 1 album related to that image. From the wording in your question, it seems you either meant to put the foreignkey field in Album or you wanted a ManyToMany field
π€skzryzg
Source:stackexchange.com