# Path: demo/library/models.py
# class Author(models.Model):
#     name = models.CharField("Name", max_length=128)
#     penname = models.CharField("Pen Name", max_length=128)
#     age = models.SmallIntegerField("Age", null=True, blank=True)
# 
#     class Meta:
#         ordering = ('name',)
#         verbose_name = "Author"
#         verbose_name_plural = "Authors"
# 
#     def __str__(self):
#         return self.name
# 
#     def double_age(self):
#         return self.age*2 if self.age else ''
#     double_age.label = "Double Age"
# 
# class Book(models.Model):
#     title = models.CharField(_("Title"), max_length=128)
#     isbn = models.CharField("ISBN", max_length=12)
#     author = models.ForeignKey(Author, on_delete=models.CASCADE)
# 
#     class Meta:
#         ordering = ('title',)
#         verbose_name = "Book"
#         verbose_name_plural = "Books"
# 
#     def __str__(self):
#         return self.title


from django.contrib import admin
from .models import Author, Book
# -*- coding: utf-8 -*-
from __future__ import unicode_literals



# Register your models here.
@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
    list_display = ('name', 'age', 'double_age')

    def double_age(self, obj):
        return obj.age*2
    double_age.short_description = "Double Age"


# Path: demo/library/models.py
# class Author(models.Model):
#     name = models.CharField("Name", max_length=128)
#     penname = models.CharField("Pen Name", max_length=128)
#     age = models.SmallIntegerField("Age", null=True, blank=True)
# 
#     class Meta:
#         ordering = ('name',)
#         verbose_name = "Author"
#         verbose_name_plural = "Authors"
# 
#     def __str__(self):
#         return self.name
# 
#     def double_age(self):
#         return self.age*2 if self.age else ''
#     double_age.label = "Double Age"
# 
# class Book(models.Model):
#     title = models.CharField(_("Title"), max_length=128)
#     isbn = models.CharField("ISBN", max_length=12)
#     author = models.ForeignKey(Author, on_delete=models.CASCADE)
# 
#     class Meta:
#         ordering = ('title',)
#         verbose_name = "Book"
#         verbose_name_plural = "Books"
# 
#     def __str__(self):
#         return self.title


# Path: demo/library/admin.py
from django.contrib import admin
from .models import Author, Book

# -*- coding: utf-8 -*-
from __future__ import unicode_literals



# Register your models here.
@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
    list_display = ('name', 'age', 'double_age')

    def double_age(self, obj):
        return obj.age*2
    double_age.short_description = "Double Age"


@admin.register(Book)