E-Mail Site Admins in Django without using mail_admins()
I know this sounds kind of stupid, but as a beginner in Django (and even Python), I just want to know how I can access the email address from the ADMINS tuple, or maybe even access the admin name.
I read that tuples are semantic, kind of like lightweight structs. So if that's the case, I may be able to access t开发者_开发技巧hose semantics and do something "dictionary-like", i.e. ADMINS['email']. Knowing this, how can I retrieve the admin email and name in the tuple?
Thanks in advance!
ADMINS
is a setting. You can access it as follows:
from django.conf import settings
settings.ADMINS
For example, to get all the email addresses as a list:
from django.conf import settings
admin_emails = [v for k,v in settings.ADMINS]
The settings docs: http://docs.djangoproject.com/en/1.2/topics/settings/
精彩评论