jazzband / wagtailmenus

An app to help you manage and render menus in your Wagtail projects more effectively

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting a limit to the creation of FlatMenu instances

heav1811 opened this issue · comments

commented

Hey,
hope you guys are doing fine, great project!
maybe its not the the right place but, since i can't find any information on docs, i'll just ask here.

I have an instance of flat menu:

class FlatMenuXPTO(AbstractFlatMenu):
    """The default model for 'flat menu' instances."""
    pass

I wanted to limit the creation of the FlatMenu's instances, overriding some method. Can this be done? What is the "default" create/save?
Maybe its just Monday...

Thanks for your help

commented

It was indeed a Monday!

for anyone that finds this issue,
On the same method as above you can just do,


  def clean(self):
      if your_logic:
          raise ValidationError('wwwww')
      return MenuWithMenuItems.clean(self)