Managing settings.py from admin site

1 view
Skip to first unread message

Julián C. Pérez

unread,
Jul 2, 2009, 7:11:31 PM7/2/09
to Django users
Hi everyone
I have a doubt...
Is it possible to edit or customize -not delete- variables created in
settings.py from the admin site of my application??
I mean, in order to control the whole site from web interface instead
of manually editing settings.py
I hope I made myself clear...
Any idea??
Thanks!

Graham Dumpleton

unread,
Jul 2, 2009, 7:22:10 PM7/2/09
to Django users
The only way you could do it is to rewrite the settings.py file and
then trigger a restart of the web server. If you were using daemon
mode of mod_wsgi, you could also just trigger restart of the specific
web application instance by updating modification time on the WSGI
script file used as entry point for the application.

Note that the safest thing to do would be to write new settings into
new file and then atomically rename file so as to replace existing
file. This avoids problem of half modified file being picked up by
newly started web server/application process.

Finally, do be aware that you would need to have really good error
checking on inputs because any small stuff up could lock you out of
your site. In some respects you might be better off having a separate
application instance for modifying the file and have that run in
separate mod_wsgi daemon process. In other words, you are never
modifying your own settings.py file, so the application you use to
edit it will never break.

Graham

Julián C. Pérez

unread,
Jul 6, 2009, 4:15:08 PM7/6/09
to Django users
Thank you, Graham
In fact... my post was just a wondering, maybe to use on personal
projects... because it would be risky in a production enviroment
Right now best thing I could do is to keep clean and isolated the
settings file

On Jul 2, 6:22 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:
> On Jul 3, 9:11 am, Julián C. Pérez <jcp...@gmail.com> wrote:
>
> > Hi everyone
> > I have a doubt...
> > Is it possible to edit or customize -not delete- variables created in
> >settings.pyfrom theadminsite of my application??
> > I mean, in order to control the whole site from web interface instead
> > of manually editingsettings.py
> > I hope I made myself clear...
> > Any idea??
>
> The only way you could do it is to rewrite thesettings.pyfile and
> then trigger a restart of the web server. If you were using daemon
> mode of mod_wsgi, you could also just trigger restart of the specific
> web application instance by updating modification time on the WSGI
> script file used as entry point for the application.
>
> Note that the safest thing to do would be to write new settings into
> new file and then atomically rename file so as to replace existing
> file. This avoids problem of half modified file being picked up by
> newly started web server/application process.
>
> Finally, do be aware that you would need to have really good error
> checking on inputs because any small stuff up could lock you out of
> your site. In some respects you might be better off having a separate
> application instance for modifying the file and have that run in
> separate mod_wsgi daemon process. In other words, you are never
> modifying your ownsettings.pyfile, so the application you use to
Reply all
Reply to author
Forward
0 new messages