Last active
December 29, 2015 16:39
-
-
Save glaucocustodio/7698532 to your computer and use it in GitHub Desktop.
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
# my_page.models.py | |
from mezzanine.blog.models import BlogCategory | |
class MyBlogCategory(BlogCategory): | |
color = models.CharField('Hexadecimal color', max_length=6, blank=True, null=True) | |
class Meta: | |
verbose_name = "My Category" | |
verbose_name_plural = "My Categories" | |
# my_page.admin.py | |
from copy import deepcopy | |
from django.contrib import admin | |
from my_page.models import MyBlogCategory | |
from mezzanine.blog.admin import BlogCategoryAdmin | |
category_fieldsets = deepcopy(BlogCategoryAdmin.fieldsets) | |
category_fieldsets[0][1]["fields"] += ('color',) | |
class MyBlogCategoryAdmin(BlogCategoryAdmin): | |
fieldsets = category_fieldsets | |
list_display = ('title', 'color') | |
admin.site.register(MyBlogCategory, MyBlogCategoryAdmin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment