Skip to content

Instantly share code, notes, and snippets.

@mrron313
Created November 12, 2019 07:45
Show Gist options
  • Save mrron313/2b2e699b38c02ebebcf5e5197cf89ff4 to your computer and use it in GitHub Desktop.
Save mrron313/2b2e699b38c02ebebcf5e5197cf89ff4 to your computer and use it in GitHub Desktop.
many to many field in django admin display list
class NewsAdmin(admin.ModelAdmin):
list_display = (..., 'getCategory', ...)
...
...
def getCategory(self, obj):
return "\n".join([cat.name for cat in obj.category.all()])
...
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment