This post is for myself to remember how to build Django project.
I did follow the tutorial from the JustDjango Learn website free tutorial.
And this is the fourth tutorial named Getting Started With Django.
I am not going over all the details and descriptions for each part. There are good explanations on video of the JustDjango Learn. So, visit their site and try their tutorials if you need more details. Also, the orders of this post and their video might be different because I put things first what I think should come first.
This post will be about basic starts.
I am doing this on Windows 10 with just Windows PowerShell. Not using virtual machines at all.
1. Prerequisite
- VSCode installed.
- Python 3.6 or above needs to be installed.
- In the JustDjango Learn, he used 3.7.4, and I used 3.9.6.
- To check your Python version,
– click start(windows logo on your computer) or hit windows logo key on your keyboard.
– type cmd or terminal to open your command line.
– If you want to do in VSCode, open your terminal by hit ctrl+` key, or click view -> terminal.
– type “python” or “python -V” - pip installed.
Pip is already installed if you already installed the Python.
To check your pip installed or version, same thing to open terminal above, then type “pip -V”
2. Starting a Project
- create a new folder for new project
- open folder on VSCode or any other IDE you use.
- create virtual environment
python -m virtualenv env
- activate virtualenv
env/Scripts/activate
- install Django. in the tutorial video using 3.1.4 version, and I installed 3.2.11 version
pip install django==3.2.11
- create requirements.txt file
pip freeze > requirements.txt
- start django project
django-admin startproject djangocrm .
- create new file name .gitignore
- in this tutorial, copied from https://github.com/github/gitignore/blob/main/Python.gitignore
- I am using the toptal, you can see how to create one in my other post. https://jnpnote.com/following-django-tutorial-todo-app-part6/
- create README file if you want to explain anything for this project
3. Git
- create repository on Github or Gitlab or others whatever you use.
- since I already have readme file and .gitignore file, I am not checking anything.
- you will see quick setup guide.
- follow whatever you need to do.
- I am following the second option of below screenshot.
- I can do the second option of above screenshot because I did intialize repository on VSCode.
- I haven’t tried clicking Publish to GitHub yet.
- I did add, and commit all the files I created, and copied the second option from the github to push the first commit.
Done for starting the project.