Issue
I am trying to create a duplicate of an original django project, but with a different secret key, database, etc. Currently, I am just copying and pasting the original project, and then deleting the manage.py file in the new file. After that, I start a new project in the file. Then, I copy the settings as well as the urls from the original project into the new project. Since I want to keep all of my pip installments, I am not going to create a new virtual env, but just copy and paste the original one from the old project(hence creating a new env with the pip installments). I am not sure if this method is okay when creating a new version of the original project. My project seems to work fine after duplicating it, but I am a little worried that there might be a security issue when deploying it, or some part of the new project may not work properly. I hope you guys could tell me if this method is okay, and if there are any better methods. Since I am a beginner, if possible, I would like to stick to this method if it is okay, instead of writing a bunch of code to duplicate my original project. Thanks a lot!
Solution
It's perfectly fine to copy a Django project. However, there's no need to mess with manage.py
. What you should be editing is settings.py
. Here, you'll change your database access parameters, secret key, and all the other settings. Personally, I go a step further and set these from a .env
file. Then the only thing I need to worry about when duplicating a project is the .env
file.
I would not recommend copying virtual environments, that's asking for headaches. Instead, use a requirements.txt
file. This is a simple text file with a list of libraries to be installed. You can create one by simply doing
pip freeze > requirements.txt
in your current project. Check this one into your source control – and spin up the new environment in the new project with
pip install -r requirements.txt
Always remember to keep api keys, passwords, and other secrets out of source control.
Answered By - John Kealy Answer Checked By - Terry (WPSolving Volunteer)