Question

newbie. I have a django project and an app. I would like to include the menu library to the whole project and "extends" to the apps through the base.html. I'm guessing the class here would go in the views.py file if I were placing the menu directly into the app. How and where would this code go if I wanted to call the class for the project?

from admin_tools.menu import Menu

class MyMenu(Menu):
    class Media:
        css = ('/media/css/mymenu.css',)
        js = ('/media/js/mymenu.js',)

Also, regarding good design. Should all html files be in/under the same directory or should the base.html be stored at myproject/templates/ then apps under myproject/app/templates/app/ hope this is coherent. thanks in advance.

Was it helpful?

Solution

So menu library itself is essentially another app that can be used by other apps and your app. App folders and project folders are usually in the same folder. Here is one layout you can use.

MyApp/MyApp/Template/...
MyApp/App1/...
MyApp/App2/...
MyApp/Menu/...

or it could be under MyApp where view.py contains your Menu code.

MyApp/MyApp/view.py/...
MyApp/MyApp/Template/...
MyApp/App1/...
MyApp/App2/...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top