How you ever wondered if you create a website using just phone? In this tutorial i will walk you through on how to create Django website using android phone.
Do you know that your smartphone can do better even what your laptop is doing? Have you been looking for how to develop a website but you do not have a laptop,or no constant electricity?
If so This Post is for you. Some people might actually have the zeal to code but because of some constrant they might just give up.
In this Post I will be introducing you to a programming language with the frame work and free tool that will help you code with even your smartphone.
What is Python
Pythonis a high-level,interpreted,general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation.
Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured (particularlyprocedural),object oriented and functional programming.
It is often described as a batteries included language due to its comprehensive standard library.
Guido van Rossum began working on Python in the late 1980s as a successor to the ABC programming language and first released it in 1991 as Python 0.9.0. Python 2.0 was released in 2000 and introduced new features such as list comprehensions,cycle-detecting garbage collection, reference counting, and Unicode support.
Python 3.0, released in 2008, was a major revision that is not completely backward-compatible with earlier versions. Python2 was discontinued with version 2.7.18 in 2020.
Python consistently ranks as one of the most popular programming languages
What is Django Frame Work
Django’s primary goal is to ease the creation of complex, database-driven websites. The framework emphasizes reusability and “pluggability” of components, less code, low coupling, rapid development, and the principle of don’t repeat yourself.
Python is used throughout, even for settings, files, and data models. Django also provides an optional administrative create, read, update and delete interface that is generated dynamically throughintrospectionand configured via admin models.
What is Pythonanywhere
PythonAnywhereis an onlineintegrated development environment(IDE) andweb hosting service(Platform as a service) based on thePython programming language.
Founded by Giles Thomas andRobert Smithsonin 2012, it provides in-browser access to server-based Python andBashcommand-line interfaces, along with a code editor withsyntax highlighting. Program files can be transferred to and from the service using the user’s browser. Web applications hosted by the service can be written using anyWSGI-based application framework.
PythonAnywhere was created by Resolver Systems,who also produced Resolver One, a Python-based Spreadsheet program.
On 16 October 2012 the product was acquired by a new company, PythonAnywhere LLP, who will develop and maintain the product in the future, and have taken on the existing development team.
The development team uses PythonAnywhere to develop PythonAnywhere, and say that its collaboration features help because they use the extreme programming methodology.
Steps Involves Designing Django Website with Your Smartphone
- Any favorite browser, for me i prefer microsoft edge
- DownloadCodeBoardkey board from play store,this is only if you are on android
- The rest are in built on your phone
Now navigate to the browser after installing codeboard keyboard, that is in couples of seconds, type inpythonanywhere.comthen go to sign up page ,create a beginner account and login, remember to write down your user name and email in case you forget.
make sure you use real email because you will confirm the accout you just created.
After confirming your account sign in then navigate to dashboard at the top right corner click bash console then it will open an online terminal like the one above.
Now we have to create a virtual environment just like your local computer.
CONSOLE
just type in the command below
mkvirtualenv –python=/usr/bin/python3.8 mysite-virtualenv
let me explain: mkvirtualenv is a command to create a virtual environment folder that will be located at bin which is for the users and the mysite-virtualenv is the name of the virtualenvironment.
After creating a virtual environment We need to install django just like our local computer do that with this command
pip install django
Once you have run the command you will see the installation as indicated below After the Installation,Django users you all know that there is Always Two command to run
- django-admin startproject
- ./manage.py startapp
Now,to run the first one we have to decide the name of the project then secondly we have to name the app too, for thesake of this tutorial we will name the project mysite and name the app myapp
django-admin startproject mysite
Done, then we have to start the app containing our views etc
cd mysite
#run this code to enter the project you have created
./manage.py startapp myapp
Now we to set up our webapp to point to our project. Navigate to web by pressing the button at top right side then first of all enter the name of your virtual environment my-virtualenv as in my case then enter the part that leads to your project for my case /home/mytuto/mysite/mysite Again enter the part that led to your webapp for my case /home/mytuto/mysite/myapp Then after doing things you have to edit the wsgi file you have to delete every thing except this below
now leave every thing like my own below
The first part you have to enter the name of folder that contains settings.py Enter it at the second place as I have indicated above.
Again enter the folder hosting settings.py i.e mysite; save it then navigate to web app yu have open before then reload.
You will notice that our debug is set to True and django is telling us to allow host of our domain therefore we need to go to mysite and go to settings.py then enter your domain in the allowed host with a single qoute e.g allowed_host = [‘benchatronics.pythonanywhere.com’ ] you can also use asterics as I have done below.
But I recommend that you should just add your domain at pythonanywhere e.g
yourusername.pythonanywhere.com
How to commit a project on github using android and termux
After saving it go back to your teeminal which you have open before then do some migrations
./manage.py makemigrations
#nothing happens here because you didn't create any stuff
./manage.py migrate
#you will see some migrations been doneby the system
Now just reload as indicated in the pics above
congratulations!!!
Next we will be configuring static files and image uploads stuff using ckeditor
To write beautiful post with ckeditor click here
leave a comment below if there is any doubt or confusion along the way