In this article, we will tell you how you can build and run a Django project on an Android smartphone. Many people cannot afford a laptop or desktop. Some people want to see their projects running on a smartphone, in this way we will tell you how to run a Django project on a smartphone.
Normally you need 2 apps for Django, a terminal and a code editor, today we will teach you how to run a Django project with these two apps only.
To edit your code, we will suggest you an app named Acode, which you can download from Playstore. Download ACode
And for the terminal we will tell you to download termux app, you can download it from here https://f-droid.org/en/packages/com.termux/
You open termux and update the package, for this you have to run this command
pkg update && pkg upgrade
Then you have to give the storage permissions
termux-setup-storage
Now you have to install Python, for this you will run this command
pkg install python3
This will install Python on your smartphone, you can check the Python version to verify.
python --version
You will get the output of the version of python python 3.11.1
you can install vertualenv
pip install vertualenv
To create virtualenv you have to run this command
virtualenv <name_of_env>
ex:
virtualenv env
Now you have to activate Virtual Environment
source env/bin/activate
Your env will be activated you will see (env) ~ $
Now you have to install Django
pip install django
Django will be installed with this command and you can create your project
You have to go to your local storage
cd storage/shared
If you list the directory, you will be shown the folders of your storage.
ls
You can create your project by creating a new directory
django-admin startproject test
You have to cd test
and create a django app
(env) ~/.../project/test $ python manage.py startapp enroll
This will create your app
Now you have to open your project in Acode app, you can do whatever you want to create in your project.
You have to run this command to run your project
python manage.py runserver
If you have any problem, you can comment or you can direct message me.
follow for more tutorial like this https://espere.in/public-profile/abdulla/