yretuta
yretuta

Reputation: 8091

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 those 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!

Upvotes: 2

Views: 972

Answers (1)

rz.
rz.

Reputation: 20037

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/

Upvotes: 8

Related Questions