Installation
This page has all the information you will need to setup your project. Here you will get to know what are the things that you will need to install before you start working on your project. Make sure you don't miss a single step.
For Windows
Install Python
Django is a Python web framework, thus requiring Python to be installed on your machine.
To install Python on your machine , follow the link https://python.org/download/, and download a Windows MSI installer for Python. Once downloaded, run the MSI installer and follow the on-screen instructions.
Once the installation is complete, open the command prompt and check the Python version by executing this command
python --version
If you encounter any problems, first make sure you have set the PATH variable
correctly. You
might need to
adjust your PATH environment variable to include paths to the Python executable and additional scripts.
For example, if your Python is installed in C:\Python34\
, the following paths need to be
added to PATH:
C:\Python34\;C:\Python34\Scripts;
Install PIP
PIP is a package manager for Python that uses the Python Package Index to install Python packages. PIP will later be used to install Django from PyPI. If you've installed Python 3.4, pip is included so you may skip this section.
pip
is pip installs packages
Step 1: To install pip first we need to download get-pip.py
file. To do that
go to this
link https://bootstrap.pypa.io/get-pip.py and save
this
file by ctrl + s
in the same file where the python is located.
Python is usually saved on this path:
C:\Users\User\AppData\Local\Programs\Python\Python310
.
Step 2: Once this file is save, open the command prompt by typing cmd
in your start
menu,then
navigate to where the get-pip.py is located in your system and run
the below given command
python get-pip.py
Now pip is installed in your system, you can check it through this command
pip --version
Install Django
Now we have everything we need to install in Django. We can easily install Django by running this command in the command prompt.
pip install Django
Aand we are done with setting up Django in our system, now you can code all you want in Django.
For Linux
Step 1: Updating System
Update your system by executing the below given command in your terminal.
sudo apt-get update
Step 2: Install Python
Although you already have python installed in your system, as it is included while installing any linux based os, but if it is not included run the following command to install python.
sudo apt-get install python3
Check the version of python through this command:
python3 -v
Step 3: Install pip
Pip is included with the python versions above 3.4. So if you have installed python version which is above 3.4 then you can skip this step
Run this command in the terminal to install pip
sudo apt-get install python3-pip
Step 4: Install Django
Now we are all set to install Django in our system. Run this command in the terminal:
pip install Django
Setting Up admiro
Now that you have installed Django in your system its time to setup the admiro theme and start creating you wonderful website.
Step 1: Check Django Version
Make Sure that Django
is installed in your system by running this command
Django --version
If it is not installed then make sure that you install it first by above given steps.
Step 2: Install dependencies
Info: Did you know
that you can directly open the terminal at any given location.
If you are using a linux system, you can just go to the folder through your gui, and right click
anywhere in the empty space and click on open in terminal.
And if you are a windows user, just navigate to the folder through your gui, and in the address bar type cmd, and the current location will open in the command prompt.
Once you have navigated to the admiro folder, make sure that you have run.py
in your
current directory,
you can check it by typing ls
in your terminal (if using linux) or dir
(if
using windows).
Now that we are in the right directory, run the below given commands to install all the dependencies one by one.
pip install libsass
Set Up a Django Project
After you’ve successfully installed Django, you’re ready to create the scaffolding for your new web application. The Django framework distinguishes between projects and apps:
A Django project is a high-level unit of organization that contains logic that governs your whole web application. Each project can contain multiple apps.
A Django app is a lower-level unit of your web application. You can have zero to many apps in a project, and you’ll usually have at least one app. You’ll learn more about apps in the next section.
django-admin startproject admiro
After Running above command creates a default folder structure, which includes some Python files and your management app that has the same name as your project:
setup/
│
├── setup/
│ ├── __init__.py
│ ├── asgi.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
│
└── manage.py
Info: Did you know
If you want to avoid creating the additional top-level project
folder, you can add a dot (.) at the end of the django-admin startproject command:
django-admin startproject .
The dot skips the top-level project folder and creates your management app and the manage.py file right inside your current working directory. You might encounter this syntax in some online Django tutorials. All it does is create the project scaffolding without an extra top-level project folder.
Set Up a Django App
Every project you build with Django can contain multiple Django apps. When you ran the startproject command in the previous section, you created a management app that you’ll need for every default project that you’ll build. Now, you’ll create a Django admiroapp that’ll contain the specific functionality of your web application.
The startapp command generates a default folder structure for a Django app. This tutorial uses admiroapp as the name for the app:
python manage.py startapp admiroapp
Note: If you created your project without the dot shortcut mentioned further up, you’ll need to change your working directory into your top-level project folder before running the command shown above.