'Hello World'This is a tutorial about how to create a Hello World app in Django. It will start with the very first steps, from Python installation to folder settings, then I will show you how to modify your Python files in order to run your first Django app. If everything is okay, you can run your app via web browser on localhost. End of this short tutorial you can turn to the next one.
Prerequisits: Windows, Python3 - https://www.python.org/downloads/windows/
Open your command-line interface or shell!
I am going to use Windows-PowerShell during the tutorials.
$ cd /set-your-path/
$ mkdir /make-your-dir/
$ cd /set-your-dir/
$ pip install pipenv
Why virtual environment? Well, if you install any Python package globally, you will end up having a bunch of installations. After a while, you do not even know which is which and so on. Package installation within the virtual environment exists only there. Accordingly, you can install different kinds of package versions for every single app if you like. I am using Pipenv in this project. https://pipenv.pypa.io/en/latest/
$ pipenv install django
Install your prefered version. The latest the version the more secure - https://www.djangoproject.com/download/
$ pipenv shell
With this command you can activate the virtual environment of your project or check if it is running.
After this you can start a new Django project and check it on the localhost.
$ django-admin startproject config .
The '.' is important at the end. So the config files will be installed in the current directory.
$ python manage.py runserver
Open your web browser!
You should see something like this on the localhost (http:\\127.0.0.0.1:8000)
Then you should stop the server (ctrl+c)
So far, we have created a new Django project on the selected path and set up a virtual environment (pipenv). We can find Python files in our project folder. So far, so good. Now, we have to add some lines of code to these files. Let's see!
First of all you should create a Django app. The name itself is up to you. My choice is 'my-helloworld-app'.
$ python manage.py startapp my-helloworld-app
Update your python files!
Open your web browser and check the running app on the localhost (http:\\127.0.0.0.1:8000)