Get secret key from django settings

104 views
Skip to first unread message

Errfan Wadia

unread,
Mar 25, 2014, 2:36:53 AM3/25/14
to django...@googlegroups.com
Hi,

I am using from django.conf import settings
Is there any faster way to get the SECRET_KEY in one of my app from settings.py ?

Shai Efrati

unread,
Mar 25, 2014, 8:18:12 AM3/25/14
to django...@googlegroups.com
Hi Errfan,
You can get the SECRET_KEY through the environment variables. Just use:

from os import environ
SECRET_KEY = environ.get('SECRET_KEY')

Good luck!


Shai.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/255c4e5c-65ad-43bf-9be0-4760c35de785%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Roseman

unread,
Mar 25, 2014, 9:01:01 AM3/25/14
to django...@googlegroups.com
What do you mean, faster? In what way is that slow?
--
DR. 

Errfan Wadia

unread,
Mar 25, 2014, 12:06:38 PM3/25/14
to django...@googlegroups.com
Hey Shai

it worked, reduced the time to 10 millisec from 120 millisec.

Errfan Wadia

unread,
Mar 25, 2014, 12:08:59 PM3/25/14
to django...@googlegroups.com
Hi Daniel,

When I try to get the SECRET_KEY from settings.py in one of the app, it takes around 110-130 millisec. Here I am talking about execution time.

François Schiettecatte

unread,
Mar 25, 2014, 12:36:13 PM3/25/14
to django...@googlegroups.com
110-130 milliseconds to 'import' something, sounds very suspect to me.

François
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/be8a456f-1f0e-47bd-9116-94ac54304b3d%40googlegroups.com.
signature.asc

Errfan Wadia

unread,
Mar 26, 2014, 12:34:37 AM3/26/14
to django...@googlegroups.com
Yes because it takes the settings instance using the lazysettings.
Reply all
Reply to author
Forward
0 new messages