how to use django mailer without PINAX

自古美人都是妖i 提交于 2020-01-12 10:15:18

问题


I want to use django-mailer without PINAX. When I run ./manager.py send_mail it prints:

Unknown command: 'send_mail'
Type 'manage.py help' for usage.

How do I fix this?

Python 2.5.1 (r251:54863, Sep 22 2007, 01:43:31) 
[GCC 4.2.1 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.conf import settings
>>> 'mailer' in settings.INSTALLED_APPS
True
>>> 

$./manage.py send_mail
Unknown command: 'send_mail'
Type 'manage.py help' for usage.

and I used easy_install django-mailer to install the mailer, and the django version is

    VERSION = (1, 1, 1, 'final', 0)

and mailer version is 0.1.0


回答1:


A few things to double check:

  1. Did you install django-mailer?
  2. Is mailer in your PYTHONPATH? When you import mailer, are you getting the expected module (version and expected path)?
  3. Is mailer listed in your INSTALLED_APPS?
$ ./manage.py shell
>>> import mailer
>>> mailer.get_version()
'0.1.0'
>>> mailer.__file__
/PATH/TO/YOUR/PYTHON/LIBS/mailer/__init__.py
>>> # did it import?  did you get the expected version?  expected path?  
>>> # good, django-mailer is in your PYTHONPATH.  now verify project settings.
>>> from django.conf import settings
>>> 'mailer' in settings.INSTALLED_APPS
True

At this point you should see send_mail in the list of available manage.py subcommands.

$ ./manage.py --help
Usage: manage.py subcommand [options] [args]
[...]
runserver
send_mail
shell
[...]
$

After than you will also want to make sure that you are running ./manage.py send_mail via a cron job.

* * * * * (cd $YOUR_PROJECT; /usr/bin/python manage.py send_mail >> cron_mail.log 2>&1)  
0,20,40 * * * * (cd $YOUR_PROJECT; /usr/bin/python manage.py retry_deferred >> cron_mail_deferred.log 2>&1)

There is no need to actually set these two cronjobs up during development, just look for your messages via the admin.

The django-mailer module has usage instructions but this should get you up and running.




回答2:


Can't you just download it from django-mailer and install it separately?



来源:https://stackoverflow.com/questions/1819524/how-to-use-django-mailer-without-pinax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!