Here's a quick and simple tutorial on how to start a new Django project and get it ready to collaborate with others!
In this quick and easy tutorial we will:
- 1) Set up a new Django project
- 2) Use pipenv for dependency management
- 3) Upload our project to GitHub
You're computer most like already has python installed. You can check by running
python --version or
python3 --version. If it's not installed, download the latest version of python 3.x.
Once you have ensured python is installed, we just need to install 2 global dependencies. Run
pip install django pipenv. Now we are ready to go! If you want to know more, feel free to check out the docs for django and pipenv as well!
This step is easy enough! All we need to do is run this command in the folder where we want to create our Django project inside of:
django-admin startproject my_project_name Note that
-'s will not work here. Our project name must be in snake_case (like most things in python). This will create a new folder, in our cases, named
We can cd inside or open our project up in our favorite IDE (Pycharm for the win!). And there we have it! Our Django project is set up and ready to go. There are a few more commands we can run to setup our project before we get started.
python manage.py migrateto migrate our database schema for us.
python manage.py createsuperuserto create a user we can use to log into the admin panel.
Pipenv is an amazing tool we can use to setup version control. This allows us to easily save our python dependency versions so that others can others can clone our project and create an environment that downloads the same versions on dependencies we use so that nobody's project breaks because decency versions are out of sync.
pipenv --python 3.Xreplace x with the specific version, like 3.11 for example.
pipenv shellto activate the environment.
pipenv install djangobecause while Django is installed globally, it is not installed in our fresh pipenv environment.
Create a totally blank repository on GitHub with the same name as the project you created and copy the ssh url for it (unless your on windows, then do https). If you need help setting up ssh, GitHub has great documentation on how to set it up!
The blank repository will have all the docs you need to push your project up to GitHub, and now you're all set! You project is not only visible to the world, but anybody can download your project and use pipenv to install the right dependencies from your Pipfile.lock with
If you enjoyed this content and want to see more Django tutorials like, comment and subscribe to let me know you want more!