admin.site.register(Ingredient, PageAdmin)admin.site.register(Ingredient)--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
When I develop a Mezzanine site, there's usually two types of
models I use:
1. Custom Page types. These are models that users want to
incorporate into the page menu, and they must be
editable/orderable from the page tree in the admin. In this case
the model must inherit from mezzanine.pages.models.Page and the
admin class must inherit from mezzanine.pages.admin.PageAdmin.
2. Displayable models. These are models we don't want to incorporate into the page menu, we want them to have their own section in the public site and their own list-enabled admin interface. The prime example is Mezzanine's built-in blog. It has it's own admin and it's own urls to display the BlogPost list and detail views. In this case the model must inherit from mezzanine.core.models.Displayable and the admin class from mezzanine.core.admin.DisplayableAdmin.
It looks to me like you want to go with approach #2. I suggest you re-write your models to use the Displayable base model and admin.
I gave a talk last year regarding this topic at DjangoCon. It
explains how to convert a normal Django app into a
Displayable-based Mezzanine app. Hopefully it'll be useful:
https://www.youtube.com/watch?v=yVAmMXES2EU
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
--
filter_horizontal = ("categories", "related_recipes")filter_horizontal = ("categories", "ingredients", "related_recipes",)--
ingredient_fieldsets = deepcopy(DisplayableAdmin.fieldsets)
ingredient_fieldsets[0][1]["fields"].insert(1, "name")
ingredient_fieldsets[0][1]["fields"].insert(1, "other_names")
ingredient_fieldsets[0][1]["fields"].insert(1, "information")
ingredient_fieldsets[0][1]["fields"].insert(1, "how_to_choose")
ingredient_fieldsets[0][1]["fields"].insert(1, "nutrients")
ingredient_fieldsets[0][1]["fields"].insert(1, "benefits")
ingredient_list_display = ["title", "status", "admin_link"]
ingredient_fieldsets = list(ingredient_fieldsets)
ingredient_list_filter = deepcopy(DisplayableAdmin.list_filter) + ("name", "other_names", "information", "how_to_choose", "nutrients", "benefits")
class IngredientAdmin(DisplayableAdmin, OwnableAdmin):
"""
Admin class for ingredients.
"""
fieldsets = ingredient_fieldsets
list_display = ingredient_list_display
list_filter = ingredient_list_filter
filter_horizontal = ("nutrients",)
def save_form(self, request, form, change):
"""
Super class ordering is important here - user must get saved first.
"""
OwnableAdmin.save_form(self, request, form, change)
return DisplayableAdmin.save_form(self, request, form, change)
admin.site.register(Ingredient, IngredientAdmin)--
class IngredientTranslationOptions(TranslatedDisplayable, TranslatedRichText):
fields = ('title', 'description', 'keywords_string', 'information',)
translator.register(Ingredient, IngredientTranslationOptions)