How to move django project directory into a sub-directory
First the why: I would like to dockerize my Django project and I would like to keep the dockerfile in the root directory. Currently that root directory is also the Django project directory - that is, the one with `manage.py` in it. This is creating problems for me because I would like to copy an entire folder from the project directory - e.g. `myapp` to the image filesystem using docker COPY. however, the docker COPY command does not preserve the top-level directory - `myapp` in the example case - when copying but rather will copy the *contents* of the directory. Wrote the author of the comment link above, “You can try to make this less painful by copying one level higher in the src tree, if possible.”
What would be the best approach to move the source code of my project into a sub-directory within the git repository?
Please sign in to leave a comment.
Justin Vanderziel, you can create a sub-directory in your repository's root to house your Django project files, like:
After moving the files, be sure to update your
Dockerfilepaths to match the new structure. For example:In PyCharm, update the project structure under File | Settings | Project | Project Structure > mark
srcas “Sources root”. Also, make sure to adjust the Django settings under File | Settings | Languages & Frameworks | Django to reflect the new locations.