These are chat archives for django/django

29th
Jan 2016
loken
@lokenx
Jan 29 2016 02:26
New to Django and room, so first hi all!
I've a question regarding application settings. Where and what is the best way to store application settings. Stuff like API keys or variables that the person running the app may want to change. I was looking at configobj but it doesn't feel very django like (whatever that is)
Should I make a model/db for this and only have a single object, or what's the general thinking?
Peter Bittner
@bittner
Jan 29 2016 07:49

@lokenx You want the Django settings file settings.py. https://docs.djangoproject.com/en/1.9/topics/settings/

A Django settings file contains all the configuration of your Django installation.

Job Matheka
@jobm
Jan 29 2016 07:52
@lokenx if am got you right what you want to do is create a file and store all the settings you don't want staged like the API key,then import that on your settings. py file. Hope it's what you meant.
Filip Figiel
@megapctr
Jan 29 2016 10:13
@ojengwa that's because nothing imports your signals.py module
If you don't have a lot of signals, you could try moving these signals to your models.py file
Else, you could import signals.py at the very end of your models.py file (then signals can import your models with no problem)
loken
@lokenx
Jan 29 2016 14:15
Thanks guys! However, what if I want these settings changeable by the user, but not by modifying the files directly but through a form or something on the site. I though you shouldn't mess with the settings.py file while running
Filip Figiel
@megapctr
Jan 29 2016 14:42
@lokenx correct, even more - changing settings during runtime would have no effect
(unless there's a method for that, but I don't remember anything like that)
You could have a model for these settings and read keys etc from there
Though I don't think you should keep things like these in the db
loken
@lokenx
Jan 29 2016 14:44
That's what I assumed, so that's not the way to go. Do people not have settings that can be changed by the admin regarding the app while running then? Or is configobj the way to go, although it seems rather old and not sure if it's ok in Python 3
Yeah db wouldn't really work either, I only need a single copy of the settings...
Filip Figiel
@megapctr
Jan 29 2016 14:45
@lokenx: just redeploy when you want to change settings.. I don't see why you would want to let users manage server settings
loken
@lokenx
Jan 29 2016 14:50
@megapctr it's meant to be run and deployed by the end user, so they would need to manage server settings. But I'd rather it through a web interface like admin one than py files. Just trying to see if configobj is the only game in town
Filip Figiel
@megapctr
Jan 29 2016 15:06
you could generate a json interactively with a django management command
(json or whatever format you like)
loken
@lokenx
Jan 29 2016 19:12
Hmm not sure I get what you're saying @megapctr