Strangely enough, I fixed this by accident. 

Turns out, (If my accidental fix is what did it), you need to unregister 
and reregister the BlogPost before you can do the same to BlogCategory. 
Here's my final admin code:

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

class CustomBlogPostAdmin(BlogPostAdmin):
fieldsets = blog_fieldsets

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


cat_fieldsets = deepcopy(BlogCategoryAdmin.fieldsets)
cat_fieldsets[0][1]["fields"] = ("title", "is_visible")

class CustomBlogCategoryAdmin(admin.ModelAdmin):
fieldsets = cat_fieldsets
list_display = ("title", "is_visible",)

admin.site.unregister(BlogCategory)
admin.site.register(BlogCategory, CustomBlogCategoryAdmin)



On Tuesday, April 28, 2015 at 1:17:51 PM UTC-6, Kyle Swanson wrote:
>
> I am trying to add a field to BlogCategory to specifiy the visibility of a 
> category on the site. 
>
> Using settings.py I have this.
>
> EXTRA_MODEL_FIELDS = (
>     (
>         # Dotted path to field.
>         "mezzanine.blog.models.BlogCategory.is_visible",
>         # Dotted path to field class.
>         "BooleanField",
>         # Positional args for field class.
>         ("Category Is Visible",),
>         # Keyword args for field class.
>         {"default": True},
>     ),
> )
>
> I have created the migration and run it and all seems okay. I have checked 
> the database and the new column exists. 
>
> The problem happens when I try register blog category on the admin. 
> First, I tried adding BlogCategory to the ADMIN_MENU_ORDER. This let's me 
> manage them in a table, but my new field isn't there, which I expected. 
> So I tried unregistering the model, then reregistering.
>
> However, when I unregister it states:
> NotRegistered: The model BlogCategory is not registered
>
> More puzzling, when I try to register (with or without the unregister) I 
> get: 
> AlreadyRegistered: The model BlogCategory is already registered
>
>
>
>
> My only goal is to add a simple Boolean field to the BlogCategory admin, 
> and if able make the list view more elaborate as well. Any solution would 
> be great!  
>
>
>

-- 
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 mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to