- Editor being used: PyCharm
- Python version: 3.7
- Django version: 3.0.2
Django 3 Setup
We start our PyCharm editor and write the name of our project after clicking File > New Project. I set the name of my project as KernelBlogDjango. The essential part here is to use a virtual environment. Thanks to the virtual environment, our computer is not affected by the Python modules we will add later.
After clicking Create, we add Django to our virtual environment Virtualenv using the pip command. For this, we use the terminal that PyCharm gives us (you can find it from the bottom left corner). Make sure that our terminal is at the beginning (venv) of our file path.
To install Django, we write the following command;
Let’s Create Our Django Project
Now, let’s entirely create our project. To create a Django project, we create it with the command that comes up on the terminal screen when we install Django.
Here Django-admin is a command that comes up when we install Django. When we create a new project, we use the startproject command and give a name to our project. The dot at the end is to create the folder we are in.
After giving the command, there is a folder named kernelblogdjango and a module named manage.py on the left. There are several different modules in our folder.
- settings.py: To write the settings of our project.
- urls.py: Module where we define web addresses.
- wsgi.py: To provide a standard interface between our Django project and the server.
- manage.py: Module that we need to manage our project, we will use it in almost every process.
Let’s launch our project on localhost by typing the following commands;
Our terminal will give us the address http://127.0.0.1:8000/ where our server works. When we open the address, we see the default Django screen. He states that our project is working properly. Now we have created our first project, but the default screen of Django is in English, so our project is in English, we open the settings.py module to fix this and change the final codes as follows;
LANGUAGE_CODE = ‘tr’
TIME_ZONE = ‘Europe / Istanbul’
Save and our project is now Turkish. We do not have to stop our running server while doing this process, the welcome screen is in Turkish when we refresh the page.
You can learn more in Django’s documentation.
Our other articles about Django: