Django 通知——create_notice_type 被炒作了?以及其他问题
我一直打算在我的 django 应用程序中使用 django-notification 。
对于我的经验水平有限的人来说,这些文档有点稀疏。我需要对其用法进行一些澄清。
- 在项目的usage.txt中,在 “创建通知类型”部分 说:
您需要调用一次
create_notice_type(label, display, description)
在数据库中为您的应用程序创建通知类型。
在与自己争论了很多之后,我觉得我真的“不需要”这样做。目标是在数据库中创建通知类型的记录,因此我可以使用管理部分中的 django-notification 选项很好地做到这一点。我说得对吗?
我认为 create_notice_type 在分发应用程序以使其可插拔时很有用。
- 在项目的usage.txt中,在 “通知模板”部分 说:
可以为通知的实际内容编写四种不同的模板:......... 每一个都应该放在模板路径上名为
notification/ 的目录中
。如果缺少其中任何一个,将使用默认值。/
这些默认模板是什么?他们需要居住在哪里?将文档中提到的四个模板放在模板加载器路径中的“通知”目录中是否足够?
- 从项目中可以看出 views.py 第 43 行,模板 使用“notices.html”。第 53 行使用 "single.html" 。但是 项目不提供这些 模板位于其目录中的任意位置 结构。那里发生了什么事?
I have been intending to use django-notification in my django app.
The docs are a little sparse for someone with my limited level of experience. I need a couple of clarifications about its usage.
- In the project's usage.txt, under the
section "Creating Notice Types" it
says:
You need to call
create_notice_type(label, display, description)
once to
create the notice types for your application in the database.
After debating this with myself quite a lot, I feel like I don't really "need" to do that. The objective is to create records for notice types in the database, so I can very well do that using django-notification's options in the admin section. Am I right?
I think create_notice_type is useful when one is distributing apps so that they are pluggable.
- In the project's usage.txt, under the
section "Notification templates" it
says:
There are four different templates that can to be written for the actual content of the notices: .......... Each of these should be put in a directory on the template path called
notification/<notice_type_label>/<template_name>
. If any of these are missing, a default would be used.
What are these default templates? Where do they need to reside? Is putting the four templates mentioned in the docs in a "notification" directory in the template loader path sufficient?
- As can be seen in the project's
views.py line 43, the template
"notices.html" is used. Line 53 uses "single.html" . But the
project does not provide these
template anywhere in its directory
structure. What is going on there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。您可以稍后通过管理员添加或删除它们。它只是让您可以轻松地在代码中使用相同的通知类型,而不必担心每次都完全正确。例如,如果您在开发时使用相同的通知类型并不断重置您的应用程序(像我一样),这可以节省大量时间。
django-notifications 包含 notification/templates 中所需的大部分基本模板,但它仍然缺少 single.html。要使用您自己的模板,请将它们放在 /template-path/notification/template_name 下的常用模板目录中。这将覆盖默认值。您还可以使用 /template-path/notification/noticelabel_noticeformat 格式为每种通知类型添加精细模板。
Yes. You can add or remove them via the admin later. It just makes it easy to use the same notice types in your code without worrying about getting them exactly right every time. For example if you are using the same notice types and constantly resetting your app while you're developing (like me) this can be a big time saver.
django-notifications includes most of the basic templates you need in notification/templates, however it is still missing single.html. To use your own templates, put them in your usual template directory under /template-path/notification/template_name. This will override the defaults. You can also add granular templates for each notice type by using the format /template-path/notification/noticelabel_noticeformat.