How To Install Django On Android [With Pictures]
Install Django On Android
Nowadays, Python is the most popular Programming Language in the world; the one reason for its popularity is that it is incredibly easy to learn and use.
Python is interpreted as a high-level programming language for general-purpose programming. You can use it for both Desktop and Web Applications Development.
There are a few frameworks that provide us the ability to develop web applications in Python, like Django, Flask, Tornado, Falcon, Hug, Sanic, aiohttp, Pyramid, etc.
The most popular Python Web Framework is Django.
In this article, you will get the ultimate guide on how to install Django on Android.
Let’s Get Started…
Video Tutorial
Step 1:
First of all, you will need a terminal; in my opinion, Termux is the best terminal for Android.
Download it from the below link
Step 2:
Download Hacker’s Keyboard
This keyboard allows you the Ctrl, Alt, Esc, Arrow keys.
Download it from the below link
Step 3:
Open Termux.
And install Python by entering the following command
pkg install python
Python setup size is about 5.4 MB
Python has been downloaded successfully.
Step 4:
Create a new directory for Django
Use the following command to check your current directory
pwd
To create a new directory, use the following command
mkdir directory_name
I am creating a ‘Django’ directory
After creating a new directory, enter it by
cd directory_name
Step 5:
Install Virtual Environment to create environment for your project. For this, use this command
pip install virtualenv
After installing the virtual environment, create a virtual environment by using this command
virtualenv env
Then activate the virtual environment with the following command
. env/bin/activate
After environment activation, install Django in the same directory where you have installed virtual environment, by typing
pip install django
You can check your Django version by using the following command
django-admin --version
Step 6:
Create a Django Project
To create a new project, use the following command
django-admin startproject testsite .
Here I am creating a “testsite” project.
After creating a project, you can see your project by this command:
ls
Now use this command for migration
python manage.py migrate
Step 7:
This is the last step
Here we will run the server.
Use the following code to run the server
python manage.py runserver
The server has started successfully.
Now, open your browser and enter the default Django server address.
http://127.0.0.1:8000/
And hit the enter key
You will see the Django welcome page
It means Django has been successfully installed.
You can close the server by pressing Ctrl+C
Now, if you have any questions, don’t hesitate to let me know through comment or email, I will try to help you.
If you found this article helpful, then please Subscribe to our YouTube Channel for video tutorials, and share this article on social media.
Do I need a PC to do this
You can do it both on mobile and PC
I have gone throug all the steps and it worked so thank you
My Pleasure
All works fine on Samsung tab, many thanks!
Infelizmente nao funciona
Aki foi de boa
Amazing tutorial thanks alot
Great post and thank you. I am a little stuck on the [virtualenv env] command in Step 5. It is returning the error:
PermissionError: [Errno 1] Operation not permitted: ‘python’ -> ‘/storage/emulated/0/Python/Django_base/env/bin/python3’
Note that I had to enable app permissions for Termux to be allowed to create directories etc. Do I need to enable further permissions to continue past this step?
Any help will be greatly appreciated. I’m about to start a course on Django and have an Android Tablet to work on.
Cheers,
David
You need to grant read/write permission for Termux app. Do it from Apps manager (system app in Android devices)
Thank you very much. Very helpful.
thanks you are the best
it really worked thanks
all the way from nigeria , Thank you so much you are the best. It works perfectly.
I dont have manage.py file in the directory , someone else with that issue ? Should i create it on my own or is it created automatically ?
manage.py file will create automatically, if you didn’t find it, then you should delete the old directory and retry the whole process.
Hi, I am stuck in step 6. I keep getting “django-admin: command not found.”
How do I get rid of this?
Am through with the installation
Now how can I start coding my Django codes on the android
This is really amazing. I’ve almost gave that I can only use my Pydroid 3 to script. But this worked well. The only issue I’m having now is this. The URL given refused to open on my browser. What can I do?
i din’t see my django project folder on my phone storage
Man thanks a lot ???? for your steps ????
They are working well
At the last step I’m getting error as “cant open file no such file or directory”
That port maybe already in use, tell Django to use a different port by entering python manage.py runserver 8001 and cycle through higher numbers until you find an open port.
Thanks so so much
you made everything easy like ABC
How can i start work on django , i did all what you said but i can’t find the djangi file in my files?
I am stuck on python manage.py migrate.
~/my-django $ virtualenv venv
created virtual environment CPython3.11.6.final.0-64 in 1828ms
creator CPython3Posix(dest=/data/data/com.termux/files/home/my-django/venv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/data/data/com.termux/files/home/.local/share/virtualenv)
added seed packages: pip==23.2.1, setuptools==68.2.0, wheel==0.41.2
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
~/my-django $ venv/bin/activate
bash: venv/bin/activate: No such file or directory
~/my-django $ . venv/bin/activate
(venv) ~/my-django $ django-admin –version
4.2.6
(venv) ~/my-django $ django-admin startproject webtest
(venv) ~/my-django $ ls
venv webtest
(venv) ~/my-django $ python manage.py migrate
python: can’t open file ‘/data/data/com.termux/files/home/my-django/manage.py’: [Errno 2] No such file or directory
(venv) ~/my-django $ ls
venv webtest
(venv) ~/my-django $ python manage.py runserver
python: can’t open file ‘/data/data/com.termux/files/home/my-django/manage.py’: [Errno 2] No such file or directory
(venv) ~/my-django $ python manage.py migrate
python: can’t open file ‘/data/data/com.termux/files/home/my-django/manage.py’: [Errno 2] No such file or directory
(venv) ~/my-django $