jazzband / wagtailmenus

An app to help you manage and render menus in your Wagtail projects more effectively
MIT License
398 stars 138 forks source link

Setting a limit to the creation of FlatMenu instances #436

Closed heav1811 closed 2 years ago

heav1811 commented 2 years ago

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

heav1811 commented 2 years ago

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)