V
V
Vladimir Kuts2016-10-11 17:47:56
Django
Vladimir Kuts, 2016-10-11 17:47:56

Pass array through environment variables?

Let's say there is a certain model in django with a field of this type:

class SomeModel(models.Model):
     ...
     some_field = models.CharField(max_length=4, choices=some_choices)
     ...

Moreover, some_choices must be obtained through environment variables. Preferably something like this:
some_choices = os.getenv('SOME_CHOICES', some_default_choices)

While constructions of the form come to mind:
SOME_CHOICES_KEY1=
SOME_CHOICES_VALUE1=
SOME_CHOICES_KEY2=
SOME_CHOICES_VALUE2=
...

And in a script all values ​​of SOME_CHOICES_* to push in the dictionary
What still the most convenient way it is possible to make it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2016-10-11
@sim3x

Проще записать в файл и импортировать оттуда

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question