# 1. Update system and install Python tools
sudo apt update && sudo apt install python3-pip python3-venv -y
# 2. Setup Django in a Virtual Environment
mkdir ~/my_project && cd ~/my_project
python3 -m venv venv
source venv/bin/activate
# 3. Install Latest Django
pip install django
django-admin --version
# 4. Verify Ollama is still active
systemctl status ollama --no-pager
# run the server
python manage.py runserver 0.0.0.0:8000
# on windows
Then, open
http://localhost:8000 on Windows to see the Django rocket!Example:
root@kayyum-VirtualBox:~/osh# sudo apt install python3-pip python3-venv -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-pip is already the newest version (22.0.2+dfsg-1ubuntu0.7).
The following additional packages will be installed:
python3-pip-whl python3-setuptools-whl python3.10-venv
The following NEW packages will be installed:
python3-pip-whl python3-setuptools-whl python3-venv python3.10-venv
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,479 kB of archives.
After this operation, 2,897 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 python3-pip-whl all 22.0.2+dfsg-1ubuntu0.7 [1,683 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 python3-setuptools-whl all 59.6.0-1.2ubuntu0.22.04.3 [789 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 python3.10-venv amd64 3.10.12-1~22.04.15 [5,714 B]
Get:4 http://in.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 python3-venv amd64 3.10.6-1~22.04.1 [1,042 B]
Fetched 2,479 kB in 4s (707 kB/s)
Selecting previously unselected package python3-pip-whl.
(Reading database ... 216450 files and directories currently installed.)
Preparing to unpack .../python3-pip-whl_22.0.2+dfsg-1ubuntu0.7_all.deb ...
Unpacking python3-pip-whl (22.0.2+dfsg-1ubuntu0.7) ...
Selecting previously unselected package python3-setuptools-whl.
Preparing to unpack .../python3-setuptools-whl_59.6.0-1.2ubuntu0.22.04.3_all.deb ...
Unpacking python3-setuptools-whl (59.6.0-1.2ubuntu0.22.04.3) ...
Selecting previously unselected package python3.10-venv.
Preparing to unpack .../python3.10-venv_3.10.12-1~22.04.15_amd64.deb ...
Unpacking python3.10-venv (3.10.12-1~22.04.15) ...
Selecting previously unselected package python3-venv.
Preparing to unpack .../python3-venv_3.10.6-1~22.04.1_amd64.deb ...
Unpacking python3-venv (3.10.6-1~22.04.1) ...
Setting up python3-setuptools-whl (59.6.0-1.2ubuntu0.22.04.3) ...
Setting up python3-pip-whl (22.0.2+dfsg-1ubuntu0.7) ...
Setting up python3.10-venv (3.10.12-1~22.04.15) ...
Setting up python3-venv (3.10.6-1~22.04.1) ...
root@kayyum-VirtualBox:~/osh# mkdir ~/my_django_project && cd ~/my_django_project
python3 -m venv env
root@kayyum-VirtualBox:~/my_django_project#
root@kayyum-VirtualBox:~/my_django_project#
root@kayyum-VirtualBox:~/my_django_project# python3 -m venv env
root@kayyum-VirtualBox:~/my_django_project# ls
env
root@kayyum-VirtualBox:~/my_django_project# source env/bin/activate
pip install django
Collecting django
Downloading django-5.2.13-py3-none-any.whl (8.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.3/8.3 MB 3.5 MB/s eta 0:00:00
Collecting asgiref>=3.8.1
Downloading asgiref-3.11.1-py3-none-any.whl (24 kB)
Collecting sqlparse>=0.3.1
Downloading sqlparse-0.5.5-py3-none-any.whl (46 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.1/46.1 KB 611.9 kB/s eta 0:00:00
Collecting typing_extensions>=4
Downloading typing_extensions-4.15.0-py3-none-any.whl (44 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 44.6/44.6 KB 649.0 kB/s eta 0:00:00
Installing collected packages: typing_extensions, sqlparse, asgiref, django
Successfully installed asgiref-3.11.1 django-5.2.13 sqlparse-0.5.5 typing_extensions-4.15.0
(env) root@kayyum-VirtualBox:~/my_django_project#
(env) root@kayyum-VirtualBox:~/my_django_project#
(env) root@kayyum-VirtualBox:~/my_django_project#
(env) root@kayyum-VirtualBox:~/my_django_project# ls
env
(env) root@kayyum-VirtualBox:~/my_django_project#
(env) root@kayyum-VirtualBox:~/my_django_project# ls
env
(env) root@kayyum-VirtualBox:~/my_django_project# rpm -qa | grep django
(env) root@kayyum-VirtualBox:~/my_django_project# pip install djangorestframework django-cors-headers
Collecting djangorestframework
Downloading djangorestframework-3.17.1-py3-none-any.whl (898 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 898.8/898.8 KB 3.2 MB/s eta 0:00:00
Collecting django-cors-headers
Downloading django_cors_headers-4.9.0-py3-none-any.whl (12 kB)
Requirement already satisfied: django>=4.2 in ./env/lib/python3.10/site-packages (from djangorestframework) (5.2.13)
Requirement already satisfied: asgiref>=3.6 in ./env/lib/python3.10/site-packages (from django-cors-headers) (3.11.1)
Requirement already satisfied: typing_extensions>=4 in ./env/lib/python3.10/site-packages (from asgiref>=3.6->django-cors-headers) (4.15.0)
Requirement already satisfied: sqlparse>=0.3.1 in ./env/lib/python3.10/site-packages (from django>=4.2->djangorestframework) (0.5.5)
Installing collected packages: djangorestframework, django-cors-headers
Successfully installed django-cors-headers-4.9.0 djangorestframework-3.17.1
(env) root@kayyum-VirtualBox:~/my_django_project# pip install djangorestframework django-cors-headers^C
(env) root@kayyum-VirtualBox:~/my_django_project#
No comments:
Post a Comment