Created
May 1, 2020 07:12
-
-
Save hiimdoublej/dd8ec3db66cc4dd3d0b0dbfa5280381d to your computer and use it in GitHub Desktop.
owner admin not optimized
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 OwnerAdmin(admin.ModelAdmin): | |
list_display = ('name', 'owned_items') | |
def owned_items(self, obj): | |
items = Item.objects.filter(shop__owner=obj) | |
if items.count() > 0: | |
return ','.join(x.name for x in items) | |
return '-' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment