0

I'm attempting use django-notification to send an email to the admin every time a user modifies, creates or deletes a database entry. The issue is, while I have created the notice types and confirm they exist, when the actual email is sent, the email sent looks like this:

You have received the following notice from example.com:

Entry has been changed. <--- this line being the email content


To see other notices or change how you receive notifications, please go to http://example.com

Is there a way to remove the first and last lines of that email body? I don't know where this default template is located so I can't change it. Any insight would be greatly appreciated!

Kenny
  • 117
  • 3
  • 13

2 Answers2

0

You should locate the default installation directory for pip. If you use Linux it should be something like /usr/local/lib/python2.7/dist-packages if you use python2.7. Then locate the django-notification directory and change to the templates directory. And here they are!

A good idea is to copy the application to your project directory and change it here.

I simply suggest you take a look at virtualenv which will give you more flexibility for such forks.

Vincent
  • 430
  • 3
  • 13
  • I located the template file I wanted to change in : /usr/local/lib/python2.7/dist-packages/notification/templates/notification/email_body.txt. However, it's write-protected meaning any changes I make cannot be saved. Can I override this template in the admin perhaps? I tried making a changed version of the template in my template folder for the project under the same name, but it doesn't seem to have any effect. – Kenny Mar 25 '13 at 17:04
  • You should copy the entire app `/usr/local/lib/python2.7/dist-packages/notification/` to your project directory, change the ownership with `sudo chown -R login directory` and then you will be able to edit whatever you want. – Vincent Mar 25 '13 at 17:07
0

Changing system libraries are not a good idea. You can do this from your app:

1) Put the notification app below your app in settings.py

 INSTALLED_APPS = (
      # ...
      'your_app',
      'notification',
      # ...
 )

2) Create the set of base templates in your_app/templates/notification/ directory:

  • short.txt
  • notice_settings.html
  • notice.html
  • full.txt
  • full.html
  • email_subject.txt
  • email_body.txt
  • base.html
vmassuchetto
  • 1,529
  • 1
  • 20
  • 44
  • I did not suggest to change a system librairy but to copy a pip package to edit it — avoiding the need to recreate all the templates. Even if I understand your opinion, is it worth downgrading my answer? – Vincent Sep 22 '14 at 17:23
  • You're right, sorry by that. Will undo as soon as someone accepts my edit. You can let me know when that happens. – vmassuchetto Sep 22 '14 at 20:41