Created
November 12, 2019 07:45
-
-
Save mrron313/2b2e699b38c02ebebcf5e5197cf89ff4 to your computer and use it in GitHub Desktop.
many to many field in django admin display list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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