How to access .env variables with django-environ in travis ci?

Viewed 595

I'm trying to integrate travis ci with my django project using django-environ but i keep getting the same error in the travis ci build:

UserWarning: Error reading /home/travis/.../.env - if you're not configuring your environment separately, check this.

django.core.exceptions.ImproperlyConfigured: Set the SECRET_KEY environment variable

Looks like django-environ can't find the environment variable.

I already tried exporting the SECRET_KEY variable through the .travis.yml file like this: .travis.yml config. But still does'nt seem to work.

Here's my .env file: .env

And part of my settings.py: settings.py

I also tried setting the variable in the travis ci project configuration page.


Edit: I found a workaround:

Since the variables were being set but for some reason the .env file wasnt being created (or the django-environ wasnt finding the variables), I created the file manually and set it to grab the variables previously added.

I did this in the before_script part of the .travis.yml file:

.travis.yml

It's not the best solution to the problem, but it's working and I didn't find another way to solve it. Hope this helps whoever also has this problem :)

0 Answers
Related