Re: settings.configure() does not allow me to access custom variables in settings.py

2014-07-07 Thread Bill Freeman
I don't know how fussy about not using stuff from django you are, but the
following works for me:

  $ DJANGO_SETTINGS_MODULE=foo.ct python
  >>> from django.conf import settings
  >>> settings.INSTALLED_APPS

Obviously, you replace "foo" with the name of your project.  This prints my
installed apps.  For settings with defaults, middlewares, for example, you
will the default if you haven't set it in your settings file.

You must have DJANGO_SETTINGS_MODULE in the environment, though you could,
instead of using the shell, add it to os.environ (I don't think that it has
to be there for the import from django.conf, but it must be there for the
first reference to an attribute of settings, which is a lazy object).

This doesn't import much, unless you have a things implied in your project
path or settings module.  I have the currect celery boiler plate in my
project's __init__.py file, so I get a lot of stuff.  Just check
sys.modules and see if the import load is too much for you before you go
re-implementing the django.conf mechanisms.


On Fri, Jul 4, 2014 at 5:12 PM, Chen Xu  wrote:

> Hi Everyone,
> I want to access some variables in my settings.py without starting my
> server, I know I will have to run settings.configure(); however, running
> settings.configure() does not allow me to access my custom variables.
>
> What should I do with that.
>
>
> Thanks
>
> --
> ⚡ Chen Xu ⚡
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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/CACac-qbCUJ3WCDVN022%3DU6nnh40X4tYPiW8oJ6q%3DY_LTGN9Bhw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CAB%2BAj0s4def1YrqcQ2V%2B2f%3DVcxfQkngxHmU2GMs-NtNH5eLwxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: settings.configure() does not allow me to access custom variables in settings.py

2014-07-04 Thread Mike Dewhirst

On 5/07/2014 7:12 AM, Chen Xu wrote:

Hi Everyone,
I want to access some variables in my settings.py without starting my
server, I know I will have to run settings.configure(); however, running
settings.configure() does not allow me to access my custom variables.

What should I do with that.


Perhaps read in the settings file and look for the settings of interest 
using plain python. Should not take too long and it would make a useful 
little utility. If necessary, hack settings.configure() to use your 
utility when it doesn't find a Django setting. Maybe submit the 
resulting improvement as a patch?


Mike




Thanks

--
âš¡ Chen Xu âš¡

--
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+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@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/CACac-qbCUJ3WCDVN022%3DU6nnh40X4tYPiW8oJ6q%3DY_LTGN9Bhw%40mail.gmail.com
.
For more options, visit https://groups.google.com/d/optout.


--
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/53B748C2.1010306%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


settings.configure() does not allow me to access custom variables in settings.py

2014-07-04 Thread Chen Xu
Hi Everyone,
I want to access some variables in my settings.py without starting my
server, I know I will have to run settings.configure(); however, running
settings.configure() does not allow me to access my custom variables.

What should I do with that.


Thanks

-- 
⚡ Chen Xu ⚡

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CACac-qbCUJ3WCDVN022%3DU6nnh40X4tYPiW8oJ6q%3DY_LTGN9Bhw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.