Hi, what should my file structure look like when creating a Django project with pipenv?
My problem now is that the Git repo is within the project folder rather than the virtual env-folder, which means I don’t commit my Pipfile and lock file.
I’ve seen many tutorials where they change the original file structure but I haven’t dared to try it yet…
Any examples or tips/pointers would be appreciated.
You should commit the Pipfile and Pipfile.lock files.
Yes exactly, I realise this, but I don’t know how my file structure should look like. Do I init the Git-repo in the virtual-env folder? That seems “odd”…
No, you don’t.
Look at my repository where I am using Django and Pipenv: https://github.com/egorsmkv/simple-django-login-and-register
Great, just what I wanted but wow, it’s nothing like the original file structure. Do you create a new project named source or do you create a project in source/ and call it app?
I’ve wanted to run production and dev settings but haven’t figured out how. I will look at your project and see if i can setup a similar file structure, thank you.
Yes, the source folder is just a place where Django code lives, nothing special.
Correct, I’ve splitted the settings.py file to dev and production environments.
Using pipenv doesn’t alter the structure of your project layout - that’s up to you.
- Create your Django project (in e.g.
~/dev/myproj
) - Set up the layout however it makes sense for your project
- Initialize with
pipenv --python 3.7
# or similar - Create or place your Pipfile in the project root folder
- Commit / push the containing directory, which is your project. It will include your Pipfile and Pipfile.lock
The actual virtualenv dir will be created elsewhere, automatically, e.g. at /Users/you/.local/share/virtualenvs/myproj-j3js86
.
It isn’t and shouldn’t be part of your project dir.