Questions tagged [django-environ]

14 questions
2
votes
0 answers

django-environ can't read docker container variables

I'm using Docker containers with Django. In my container I'm using environment variables via .env file container_name: env_file: .env I have echoe'd SECRET_KEY after the container is up and it shows the correct value set in .env file. The…
Eduardo Gomes
  • 492
  • 3
  • 11
2
votes
2 answers

Django - How to create and migrate two tables for development and production on same database? (prefix in front when running as dev)

I am trying to have two tables in one database like below based on development and production environment. development dev_my_comments production my_comments I tried using environment variable while declaring table like below class…
Praveen
  • 346
  • 1
  • 6
  • 18
2
votes
1 answer

How do I replace MemcachedCache with PyMemcacheCache in Django?

I'm running my website on Django 3.2. I read in Django’s cache framework that MemcachedCache and python-memcached are deprecated. I installed pymemcache==3.5.0 on my staging server and changed to CACHE_URL=pymemcache://127.0.0.1:11211 in env.ini.…
Uri
  • 2,992
  • 8
  • 43
  • 86
1
vote
2 answers

django-environ and Postgres environment for docker

I am using django-environ package for my Django project. I provided the DB url in the .env file, which looks like this: DATABASE_URL=psql://dbuser:dbpassword@dbhost:dbport/dbname My DB settings in settings.py: DATABASES = { "default":…
varnie
  • 2,523
  • 3
  • 35
  • 42
1
vote
1 answer

VS Code does not see virtual environment variables in .env file when running django

I am trying to set up a postgres connection and use virtual environment variables for the first time. I created a .env file and placed it in my settings folder but my database variable is missing each time I try to use manage.py runserver. Is…
1
vote
1 answer

How can I give a value to a Django environment variable from within the application itself?

I developed an application with its respective access login, when the user tries to log in, he must select a value that will be used throughout the execution of the application until the user closes the session. I have my project configured with…
0
votes
2 answers

Why am I getting a NoneType for Allowed Host in Django-Environ when I set allowed host?

The settings code is import os import environ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) env = environ.Env(DEBUG=(bool, False)) environ.Env.read_env(os.path.join(BASE_DIR, '.env')) the allowed host is written…
0
votes
0 answers

The X variable is not set. Defaulting to a blank string

I have a django secret key in a .env which is being read as a blank string part of the secret key is attached below SECRET_KEY=|$u6qthu06zp|$q at the point where the $ sign starts I keep getting the message level=warning msg="The "u6qthu06zp"…
0
votes
0 answers

Set correct path to environ file django

I have this project structure in Django: ├── .env ├── app │ ├── Dockerfile │ ├── Dockerfile.prod │ ├── entrypoint.prod.sh │ ├── entrypoint.sh │ ├── hello_django │ │ ├── __init__.py │ │ ├── asgi.py │ │ ├── settings.py │ │ …
0
votes
1 answer

Use a nested dict (or json) with django-environ?

I've got a nested dict format that I wanted to setup in an environment. It looks like this: DEPARTMENTS_INFORMATION={ "Pants": { "name": "Pants Department", "email": "pants@department.com", "ext": "x2121" }, …
UpDawg
  • 51
  • 6
0
votes
0 answers

ModuleNotFoundError: No module named 'sandbox': Docker Build failed with error code [1]

I'm building a django oscar commerce v 3.2 project(https://github.com/django-oscar/django-oscar) on ubuntu 20.04 on GCP with a virtual environment using python 3.8.14 and getting the following error when i run the docker build command…
0
votes
0 answers

Wrong environment in Django

I'm a beginner at Django Web Framework. At the beginning when I start Django project I didn't see venv folder like on the picture on the left. I didn't have bin, lab , .gitignore and pyvenv.cfg files on the right picture. When I made new env I see…
0
votes
1 answer

AttributeError: module 'dotenv' has no attribute 'dotenv_values'

I am installed django-environ and try to get my values from .env. I haven't problems when I run server in local, but when i run my app with docker-compose up --build I have error: Traceback (most recent call last): File "/usr/bin/docker-compose",…
0
votes
1 answer

Improperly Configured DATABASE_NAME env var

I made a .env file in the same directory as my settings.py file and have some environmental variables in there such as: secret_key, database_name, etc. However, it doesn't seem to be reading the database name correctly in the .env file. I feel like…