0

I've just set up my Python and Django project on Gitlab. Now when I make a commit and push it to Gitlab, it automatically runs my unit tests which is a good thing.

The problem is that to get it to work; I have to set my database host in Django to "postgres" which obviously won't work.

I want my local development environment to use 127.0.0.1 and the Gitlab environment to use "postgres", but I'm not sure how to go about and do that.

Here is my Gitlab configuration file:

https://gitlab.com/glamorous-systems/seductive/blob/master/.gitlab-ci.yml

Any help would be much appreciated. It took me quite awhile to get things working as I wanted them so if I can solve this problem I think everything will work out quite nicely.

1 Answer 1

1

You can set your database host like this

'HOST': os.environ.get('DATABASE_HOST', '127.0.0.1')

and define another env variable DATABASE_HOST=postgres in gitlab-ci.yml

This way you'll get what you want.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.