Search code examples
djangodjango-baton

Link directly to an App View in Django Baton Menu


Using Baton, I want to link directly to a particular view in an app.

Can fudge it by just hard-coding the URL:

    BATON = {
    "SITE_HEADER": "My App",
    "MENU": (
       
        {
            "type": "app",
            "name": "core",
            "label": "Management",
            "icon": "fa fa-cog",
            "models": (
                {"name": "client", "label": "Clients"},
                {"name": "invoice", "label": "Invoices"},
            ),
        },
        {
            "type": "free",
            "name": "docs",
            "label": "Documentation",
            "icon": "fa fa-info",
            "url": "https://www.myurl.com/docs/",
        },
    ),

Tried using "view" or "views" the way Models is done:

{
    "type": "app",
    "name": "docs",
    "label": "Documentation",
    "icon": "fa fa-info",
    "view": {"docs_general"},
},

And

{
    "type": "app",
    "name": "docs",
    "label": "Documentation",
    "icon": "fa fa-info",
    "views": ({"docs_general"}),
},

Doesn't seem to be documented.


Solution

  • The view is mapped within urls.py, so just use a soft link:

       BATON = {
        "SITE_HEADER": "My App",
        "MENU": (
           
            {
                "type": "app",
                "name": "core",
                "label": "Management",
                "icon": "fa fa-cog",
                "models": (
                    {"name": "client", "label": "Clients"},
                    {"name": "invoice", "label": "Invoices"},
                ),
            },
            {
                "type": "free",
                "name": "docs",
                "label": "Documentation",
                "icon": "fa fa-info",
                "url": "/docs/",
            },
        ),