LBRY Block Explorer

LBRY Claims • how-to-install-django-on-ubuntu

b60e62d132b697f48b6ef1b9efee0d3bcbed1ebb

Published By
Created On
28 Mar 2023 06:41:42 UTC
Transaction ID
Cost
Safe for Work
Free
Yes
How to install Django on ubuntu
First, let’s update the local package index:
sudo apt update && apt upgrade -y

Check the version of Python you have installed:
python3 -V

install pip and venv:
sudo apt install python3-pip python3-venv -y

cloning the Django repository:
git clone https://github.com/django/dja ~/django-dev

Change to this directory:
cd ~/django-dev

Create a virtual environment:
python3 -m venv vr_env

Activate it:
source vr_env/bin/activate

install the repository:
pip install -e ~/django-dev

verify that the installation:
django-admin --version


Creating a Sample Project


create a directory for your project and change into it:
mkdir ~/django-test
cd ~/django-test

create your virtual environment:
python3 -m venv my_env

Activate the environment:
source my_env/bin/activate

Install Django:
pip install django

To build your project, you can use django-admin with the startproject command. We will call our project djangoproject, but you can replace this with a different name. startproject will create a directory within your current working directory that includes:

A management script, manage.py, which you can use to administer various Django-specific tasks.
A directory (with the same name as the project) that includes the actual project code.
To avoid having too many nested directories, however, let’s tell Django to place the management script and inner directory in the current directory (notice the ending dot):

django-admin startproject djangoproject .

To migrate the database, type:
python manage.py migrate

create an administrative user:
python manage.py createsuperuser


Modifying ALLOWED_HOSTS in the Django Settings
To successfully test your application, you will need to modify one of the directives in the Django settings.

Open the settings file by typing:
nano ~/django-test/djangoproject/settings.py

~/django-test/djangoproject/settings.py
ALLOWED_HOSTS = ['your_server_ip_or_domain', 'your_second_ip_or_domain', . . .]

save and exit.

Testing the Development Server
sudo ufw allow 8000

Start the development server:
python manage.py runserver your_server_ip:8000

Visit:

http://your_server_ip:8000

http://your_server_ip:8000/admin/
...
https://www.youtube.com/watch?v=FTcehuComdo
Author
Content Type
Unspecified
video/mp4
Language
English
Open in LBRY

More from the publisher

Controlling
VIDEO
HOW T
Controlling
VIDEO
HOW T
Controlling
VIDEO
HOW T
Controlling
VIDEO
HOW T
Controlling
VIDEO
HOW T
Controlling
VIDEO
HOW T
Controlling
VIDEO
HOW T
Controlling
VIDEO
HOW T
Controlling
VIDEO
HOW T