lokenx / plexrequests-python

Django Python Plex Requests alpha
7 stars 0 forks source link

Configuration Settings #3

Closed lokenx closed 8 years ago

lokenx commented 8 years ago

Currently can only view and update the settings through the API end point. Only issue right now is how to generate the model on startup. I've temporary used manage.py loaddata default.config.json which loads the initial model.

Some ideas from someone on reddit:

Gotcha, makes sense. That seems like it would work. I'm sadly not aware of any great solution to this.

Here's a few other options I'm aware of:

  • have a singleton class/method for accessing/creating the settings. Disable add/create in admin by returning False from has_add_permission. Could load these from a file or be specified in the settings file on the initial create.
  • could possibly be done in a signal. (either pre_init or pre_save, and coerce pk=1)
  • similar to yours, but just force the id to 1 in save(). You'd still have to do separate initialization.

My preference is for the first, but it's not without problems.