django read json file with relative file path

Viewed 25

I am attempting to deploy django in production, but have an issue with a relative file path in my models.py.

When I use python3 manage.py runserver 0.0.0.0:8000, the site works fine. When I run django using http and wsgi, I get the error that the below file cannot be found. I assume this is because it is looking for the file using a relative path. How should I fix this?

This is the line in my models.py, which imports the json file.

data = open('orchestration/static/router_models.json').read() 

                                             
1 Answers

its better to store the file in your model (file field).

Related