from django.contrib import admin

from comics.accounts import models


class SubscriptionInline(admin.StackedInline):
    model = models.Subscription
    extra = 1


def email(obj):
    return obj.user.email


class UserProfileAdmin(admin.ModelAdmin):
    list_display = ('user', email, 'secret_key')
    inlines = [SubscriptionInline,]
    readonly_fields = ('user',)


admin.site.register(models.UserProfile, UserProfileAdmin)

from django.contrib import admin

from comics.accounts import models


class SubscriptionInline(admin.StackedInline):
    model = models.Subscription
    extra = 1


def email(obj):
    return obj.user.email


def subscription_count(obj):
    return obj.comics.count()


class UserProfileAdmin(admin.ModelAdmin):
    list_display = ('user', email, 'secret_key', subscription_count)
    inlines = [SubscriptionInline,]
    readonly_fields = ('user',)


admin.site.register(models.UserProfile, UserProfileAdmin)

Add subscription count to comics profile list
Add subscription count to comics profile list

  from django.contrib import admin
  
  from comics.accounts import models
  
  
  class SubscriptionInline(admin.StackedInline):
      model = models.Subscription
      extra = 1
  
  
  def email(obj):
      return obj.user.email
  
  
+ def subscription_count(obj):
+     return obj.comics.count()
+ 
+ 
  class UserProfileAdmin(admin.ModelAdmin):
-     list_display = ('user', email, 'secret_key')
+     list_display = ('user', email, 'secret_key', subscription_count)
      inlines = [SubscriptionInline,]
      readonly_fields = ('user',)
  
  
  admin.site.register(models.UserProfile, UserProfileAdmin)
  
Add subscription count to comics profile list
## Code Before:
from django.contrib import admin

from comics.accounts import models


class SubscriptionInline(admin.StackedInline):
    model = models.Subscription
    extra = 1


def email(obj):
    return obj.user.email


class UserProfileAdmin(admin.ModelAdmin):
    list_display = ('user', email, 'secret_key')
    inlines = [SubscriptionInline,]
    readonly_fields = ('user',)


admin.site.register(models.UserProfile, UserProfileAdmin)

## Instruction:
Add subscription count to comics profile list
## Code After:
from django.contrib import admin

from comics.accounts import models


class SubscriptionInline(admin.StackedInline):
    model = models.Subscription
    extra = 1


def email(obj):
    return obj.user.email


def subscription_count(obj):
    return obj.comics.count()


class UserProfileAdmin(admin.ModelAdmin):
    list_display = ('user', email, 'secret_key', subscription_count)
    inlines = [SubscriptionInline,]
    readonly_fields = ('user',)


admin.site.register(models.UserProfile, UserProfileAdmin)
