开发者

E-Mail Site Admins in Django without using mail_admins()

开发者 https://www.devze.com 2023-02-07 20:29 出处:网络
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 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/

0

精彩评论

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

关注公众号