开发者

Django-notification -- create_notice_type hyped? And other questions

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 da开发者_如何学运维tabase, 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?


I can very well do that using django-notification's options in the admin section. Am I right?

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.

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?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜