Answer the question
In order to leave comments, you need to log in
How to implement dynamic menu items on a website using mongoengine and flask?
Hello, it is necessary to implement dynamic rendering of menu items from the database.
Well, that is, there are two sections on the site "One" and "Two" - you need to dynamically add them.
Each of these sections has its own menu with its own items.
It is necessary that both sections and menu items and submenus can be added dynamically.
And how to store all this in the database?
mongoDB base
Answer the question
In order to leave comments, you need to log in
In my opinion, nested documents EmbeddedDocument
are well suited here
. Example:
class MenuItem(EmbeddedDocument):
name = StringField()
url = StringField()
sub = ListField(EmbeddedDocumentField('self'))
class Menu(Document):
items = ListField(EmbeddedDocumentField(MenuItem))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question