Question

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?
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top