从其他应用程序加载Django模板

2024-10-01 00:31:57 发布

您现在位置:Python中文网/ 问答频道 /正文

德扬戈1.9

如何从“fuselage”加载“control/templates/control/emails/fuselage\u job\u complete”模板/视图.py"? 你知道吗

我想将此模板用于django-emailit。你知道吗

我试着这样称呼它:

emailit.api.send_mail([task.user.email], {'task': task}, 'emails/fuselage_job_complete')

我得到了django.template.exceptions.TemplateDoesNotExist错误。你知道吗

我也试过这个:

emailit.api.send_mail([task.user.email], {'task': task}, 'control/emails/fuselage_job_complete')

我得到了django.template.exceptions.TemplateSyntaxError: 'site' takes at least one argument (path to a view)。你知道吗

我的项目结构:

web/
├── control
│   ├── admin.py
│   ├── apps.py
│   ├── forms.py
│   ├── handlers.py
│   ├── __init__.py
│   ├── management
│   │   ├── commands
│   │   │   ├── create_researcher.py
│   │   │   ├── __init__.py
│   │   │   ├── search_alerts.py
│   │   │   ├── sync_omop_tree.py
│   │   │   └── sync_users.py
│   │   ├── __init__.py
│   ├── managers.py
│   ├── migrations
│   │   ├── __init__.py
│   ├── models.py
│   ├── signals.py
│   ├── templates
│   │   └── control
│   │       ├── emails
│   │       │   ├── fuselage_job_complete.body.html
│   │       │   ├── fuselage_job_complete.body.txt
│   │       │   ├── fuselage_job_complete.subject.txt
│   │       ├── json
│   │       │   ├── jsontree.json
│   │       │   └── omoptree.json
│   ├── templatetags
│   │   ├── controltags.py
│   │   ├── __init__.py
│   ├── tests.py
│   ├── urls.py
│   ├── user.py
│   ├── views.py
├── db.sqlite3
├── manage.py
├── static
│   ├── css
│   ├── fonts
│   ├── images
│   ├── js
│   └── resources
├── templates
│   ├── emailit
│   │   └── base_email.body.txt
│   └── registration
├── fuselage
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   │   ├── __init__.py
│   ├── models.py
│   ├── static
│   │   ├── img
│   │   │   ├── loading.gif
│   │   │   └── loading-sm.gif
│   │   └── fuselage
│   │       ├── css
│   │       └── js
│   ├── templates
│   │   └── fuselage
│   ├── tests.py
│   ├── urls.py
│   ├── views.py
└── rocket
    ├── __init__.py
    ├── settings
    │   ├── base.py
    │   ├── dev.py
    │   ├── __init__.py
    │   ├── local.py
    │   ├── production.py
    │   ├── test.py
    ├── urls.py
    ├── wsgi.py

我的模板设置:

TEMPLATES = [
    {   
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates'),
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'django.template.context_processors.debug',
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
                'django.core.context_processors.request',
                'absolute.context_processors.absolute',
            ],
        },
    },
]

Tags: djangopy模板taskinitcontextjobtemplate
1条回答
网友
1楼 · 发布于 2024-10-01 00:31:57

它是这样工作的emailit.api.send_mail([task.user.email], {'task': task}, 'control/emails/fuselage_job_complete'),设置是正确的。电子邮件模板的语法错误。你知道吗

相关问题 更多 >