Creating a Django Project within a Git Repository

Story

When I took my first programming course, we never used Git to manage our versions as development progressed. As a result, I found myself saving multiple versions of my program as I made small tweaks before submitting. This usually meant I had about a dozen poorly name duplicates on my desktop that I had to reintegrate into my development environment. In my rush to completed one of my last programming projects of the semester, I accidentally submitted the wrong version of the assignment. Little did I know that the submitted program version did not run and resulted in an F on the assignment. After classes started enforcing use of Git, managing versions was pretty much trivial and I never had an issue like this again.

Create a New Django Project

Assumptions:
It is assumed that your project directory is called and has a virtual environment and a file before using the following commands. If you don't have them that's okay just ignore the parts that contain references to these files.

Navigate into the project directory that you would like to start the in. Make sure your installed virtual environment is activated for the following commands. For the terminal output we will ommit the to the right of the cursor for simplicity.

Note: For the last command, don’t forget the period at the end of the command. This tells django to use the current directory as the root rather than creating a new one within it.

The command should have resulted in a folder structure like this.

Create the Git Repository

Create the git repository.

We’ll have to create a file that tells Git to ignore the contents of the virtual environment and python cache files. We don't want our repository to keep track of these files because it would be redundant: the contents of are referenced in and files are compiled versions of the python files.

Create a file called ...

… and add the following contents.

If you will be using a database other than SQLite then go ahead and delete the , otherwise, add as a line in the file as well.

Now commit the remaining files.

Software Engineer