django - Add a field to Page Admin to include icon for menu item -


I have allowed the use of icons in my HTML templates, small square PNG or font-awesome:

template top-menu In HTML, I should be able to use the following:

  {{child.menu_icon_font_awesome}} # # "{child.menu_icon_image}}" instead of "icon-search" Instead of / icons / search.png   

How does anyone get these variables in the child menu nodes in the menu?

In addition, how can I get administrators to work in admin.py (very few important)?

My menu_icons app looks like this:

  import from django.db import model from django.utils.translation import # models.py ugettext_lazy form _ to cms.models. Pagemodel import django.core.files.storage Import FileSystemStorage Class OverwriteStorage page (FileSystemStorage): "" "If present, the file with the same name is deleted." Def_save (self, name, content): if self.exists (name): self.delete (name) return super (overwritestorage, self) ._ save (name, content) def get_available_name (auto, name): return name class MenuIconFontAwesome (models.Model): "" "font defined Awesom e menu icon" "" page = models.ForeignKey (page unique = true, verbose_name = _ ( "page"), editable = false) menu_icon_font_awesome = models.CharField (MAX_LENGTH = 48, verbose_name = "font excellent menu icon", blank = true) class MenuIconImage (models.Model): "defines the" image "menu" icon "" page = models.ForeignKey (page , Unique = s , Verbose_name = _ ("page"), editable = false) menu_icon_image = model .imageField ('menu icon image', = 'menu_icons /' upload_to, empty = true, null = true) #method from admin.py to cms .models.pagemodel import page MenuIconFontAwesome, the MenuIconImage import cms.admin.pageadmin import PageAdmin django.contrib import administrator square MenuIconFontAwesomeAdmin (admin.TabularInline): ( 'menu_icon_font_awesome: "" model = MenuIconFontAwesome fieldsets = ((' with the font menu Icon very nice ',' 'field' "" "field adds a great font for the menu icon", '),}),) the square menu inimage admin (admin.T AbularInline): "" "Adds field to image menu icon" "model = MenuIconImage fieldsets = (('Menu icon uploaded image', '' fields ': (' menu_icon_image ','),})) PageAdmin.inlines.append (MenuIconFontAwesomeAdmin) PageAdmin.inlines.append (MenuIconImageAdmin) admin.site.unregister (page) admin.site.register (page Prishtadmin) # views.py # this is the part that I can not understand   

Here the tip for navigation modifier has been used to give this error, I'm sure there is something I'm missing clearly OE "type object 'MenuIconFontAwesome' attribute 'menu_icon_font_awesome' is."

 from menus.menu_pool import menus.base import modifiers  model menu_pool MenuIconFontAwesome, MenuIconImage class MenuIconsMod (modifier) ​​imports " "" "def modified (self, request, nodes, namespace, Root_id, post_cut, breadcrumb) Add menu icons to" menu nodes ": instead of nodes: if node post_cut nodes: node.menu_icon_font_awesome = MenuIconFontAwesome.menu_icon_font_awesome Node.menu_icon_image = MenuIconImage.menu_icon_image Return Nodes menu_pool.register_modifier (MenuIconsMod)   

fieldsets In Are; That which I see looks like this, just like the way those fieldets can not get those names and how to override them.

After a

menu modifier (), you can use any of the customized data in NavigationNode.attr property Should be able to add.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -