#Help on using django with docker

1 messages · Page 1 of 1 (latest)

north flicker
#

I am new to the django and I am writing first Django app, part 1. To access app from the browser I need to add the ip address in the Allowed_hosts. my question is : How can I add or change setting.py from the docker file.

long tusk
#

You can pass an env var using arg but you can also just define * in settings for local dev

north flicker
#

How can I use the env in setting.py as I am unable to access the setting.py in dockerfile. To use * I have to do it manually right ? or is there any workaround ?

long tusk
#

to use what? what do you mean by manually? what do you mean by accessing a file from dockerfile?

#

you may want to share what do you have and what have tried, the context is not rich enough that we can understand and try to help

north flicker
storm thunder
north flicker
hoary trellis
#

You have not shared enough info for us to help you

snow pond
#

You can access anything inside a docker container by using the CLI. The command to enter a docker container and interactively work in it like it’s an OS is docker exec -it <name-of-container> (then your command, like ‘bash’)

#

Docker exec -it mydjango_container bash

#

Something like that, iron out the details with ChatGpT.

Then you can be inside your docker container and work like any Linux box:

ls
cat settings.py
Nano settings.py (to make changes)

Last time I checked that’s how I interacted inside my docker containers. Please double check with 🤖 chatbot

tulip plank
#

So you are writing your first django app which is still in development?

Basically you volume mount your project into the container, so you can just easily alter the settings.py from within your ide.

tiny anvil