Django is a Python web framework for full-stack web application development and server development that enables rapid development of secure and maintainable websites. It is the most used framework for web development in Python programming language. As an open source project that supports the implementation of the most popular packages and Python tools, Django is a perfectly suitable choice for a mobile application backend.
Many global companies are using Django, like Instagram, National Geographic, Mozilla, Spotify, Pinterest, Disqus, Bitbucket, Eventbrite.
Installation
Download and Install Python from: https://www.python.org/downloads/
After that you can install Pipenv, a packaging tool for Python that simplifies dependency management. (https://realpython.com/pipenv-guide and https://pipenv.pypa.io)
In terminal/cmd window type: pip install pipenv
Download and Install VSC – Visual Studio Code editor: https://code.visualstudio.com
After installation, run VSC and in Extensions panel search for Python and install (if already isn’t installed): Python IntelliSense extension.
After that run terminal/cmd, create folder called storefront , enter the folder and type inside that folder: pipenv install django
Open folder storefront in VSC (or drag&drop iside VSC from explorer)
In terminal/cmd type: pipenv shell
and after that type: django-admin startproject storefront .
to start a new project.
To start development server, type in cmd: python manage.py runserver
Default port number is 8000. I you want to use other port number: python manage.py runserver 8800
Now we can enter address and port number we get as a result in the browser, for example: http://127.0.0.1:8000
In VSC open View menu end select Command Palette…
In search box type python interpreter
and select Python: Select Interpreter
Click on Enter interpreter path …
Now type in terminal/cmd: pipenv --venv
and copy the path into Enter interpreter path… field.
At the end of the path append: \Scripts\python
(/bin/python if you are in Linux enviroment)
(something like, for example: C:\Users\G2.virtualenvs\storefront-QPOIJ0Ev\Scripts\python)
Now we can go to View menu in VSC and select Terminal and in terminal we can type: python manage.py runserver
(If you got error that running scripts is disabled on this system, you can try to open new terminal window clicking on + button in terminal window and type again python manage.py runserver
. – defaultProfile is known not to work on the initial restored terminal. The same solution is if you sometime got error SyntaxError: invalid syntax)
second solution:
PowerShell by default restricts running scripts unless we change the execution policies.
In VSC open View menu, select Command Palette and search settings.json.
Select Open Workspace Settings(JSON) and add following lines:
{
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell",
"args": ["-ExecutionPolicy", "Bypass"]
}
},
"terminal.integrated.defaultProfile.windows": "PowerShell",
}
After that we need to restart VS Code and the Terminal.
For more info go to: https://docs.djangoproject.com/en/4.1/intro/install/ and https://www.youtube.com/watch?v=rHux0gMZ3Eg