Just have a quick question on how to do this properly. I've read through a 
lot of the documentation but I am still a little stuck. Using a brand new 
mezzanine-project I am attempting to add a field to a blog post by 
subclassing BlogPost. 

Here's how my code is set up:

# myapp/models.py

from django.db import models
from mezzanine.blog.models import BlogPost

class ExtendedBlogPost(BlogPost):
boolean_field = models.BooleanField(verbose_name=("A Boolean Field"), 
default=True)


I can migrate and the field is added successfully:

$ python manage.py makemigrations

Migrations for 'theme':
  0001_initial.py: 
    - Create model ExtendedBlogPost



However the problem is when I try to register the field in the admin, like 
this:

# myapp/admin.py

from copy import deepcopy
from django.contrib import admin
from mezzanine.blog.admin import BlogPostAdmin
from mezzanine.blog.models import BlogPost

blog_fieldsets = deepcopy(BlogPostAdmin.fieldsets)
blog_fieldsets[0][1]["fields"].insert(-2, "boolean_field")

class MyBlogPostAdmin(BlogPostAdmin):
    fieldsets = blog_fieldsets

admin.site.unregister(BlogPost)
admin.site.register(BlogPost, MyBlogPostAdmin)



I am getting this error when trying to view admin/blog/blogpost/


Unknown field(s) (boolean_field) specified for BlogPost. Check 
fields/fieldsets/exclude attributes of class MyBlogPostAdmin.



Thanks! 

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to