I want to create multiple submenus for different pages of a website. So, I created a snippet called "Submenus".
The submenu contains an object called submenu_items. On the webpage, that translates to the top level of navigation. Then, each submenu_item has a dropdown_items. That way, under each top level link, I can create a dropdown with more links.
Problem:
Whenever I create a new submenu_item, it creates 3 dropdown_items (example in photo below). I expected for it to provide the ADD DROPDOWN ITEM button. Then, I would create one at a time as necessary. The code seems to generate three by default.
I tried deleting them, saving the snippet. But when I click on the snippet, they are there again. I tried recreating the entire model and re-migrating everything. I still get the same problem.
Can someone point out what I may be doing wrong? Is there some rule for nested elements I'm missing?
@register_snippet
class Submenu(ClusterableModel):
text = models.CharField(max_length=255)
subsite_url = models.CharField(max_length=255)
panels = [
FieldPanel('text'),
FieldPanel('subsite_url'),
InlinePanel('submenu_items', label="Submenu Items"),
]
def __str__(self):
return self.text
class SubmenuItem(ClusterableModel, Orderable):
page = ParentalKey(Submenu, on_delete=models.CASCADE, related_name='submenu_items')
menu_item = models.CharField(blank=True, max_length=250)
internal_url = models.CharField(blank=True, max_length=250)
panels = [
FieldPanel('menu_item'),
FieldPanel('internal_url'),
InlinePanel('dropdown_items', label="Dropdown Items"),
]
class DropdownItem(Orderable):
page = ParentalKey(SubmenuItem, on_delete=models.CASCADE, related_name='dropdown_items')
menu_item = models.CharField(blank=True, max_length=250)
internal_url = models.CharField(blank=True, max_length=250)
panels = [
FieldPanel('menu_item'),
FieldPanel('internal_url'),
]