Skip to content

Instantly share code, notes, and snippets.

@hiimdoublej
Created May 1, 2020 07:12
Show Gist options
  • Save hiimdoublej/dd8ec3db66cc4dd3d0b0dbfa5280381d to your computer and use it in GitHub Desktop.
Save hiimdoublej/dd8ec3db66cc4dd3d0b0dbfa5280381d to your computer and use it in GitHub Desktop.
owner admin not optimized
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