直接链接到 Django 指挥棒菜单中的应用程序视图

问题描述

使用 Baton,我想直接链接到应用中的特定视图。

可以通过硬编码 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/",

尝试使用“视图”或“视图”来完成模型:

{
    "type": "app","view": {"docs_general"},

{
    "type": "app","views": ({"docs_general"}),

似乎没有记录。

解决方法

视图映射在 urls.py 内,因此只需使用软链接:

   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/",