Answer the question
In order to leave comments, you need to log in
How to make a menu with GenericForeignKey?
Hello!
It is necessary to make editing the site menu convenient for the admin, like on wodpress, for example. I started to move towards GenericForeignKey, but manually choosing the object id can hardly be called convenient. I'm thinking of somehow implementing the selection of an instance of the select type within the framework of 4 models, i.e. replace object_id = models.PositiveIntegerField() with something more elegant
Answer the question
In order to leave comments, you need to log in
do not make any Foreign keys and other objects.
Do a regular model with a url field. It is much simpler and clearer, and the structure in the database will be normal.
There are also ready-made menus https://djangopackages.org/grids/g/navigation/ , you can use any of them.
Well, if you really want a selection by objects, just add a custom modal window in the admin panel
with lists of objects. When you select an object, generate a url based on it and create a menu item with this url (You don't need to link anything)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question