Running Django Applications in iPad

Jung-Hyun Nam
Mar 15 · 5 min read
Image for post
Image for post
https://unsplash.com/photos/Y0I5DEbx8ck

Have you ever wondered does iPad or iPhone supports a terminal for its environment? Well, yes. As you know, the free and open-source applications named iSH does.

iSH does not require any hacks or jailbreaks. iSH performs emulation in itself, and some interop features also supported including socket listening, file sharing, etc. So you can rely on it, as the battery performance as allow.

Recently, I found that this approach works quite well. So I decided to share this tip. I will introduce you to how to run your Django application in iPadOS step by step.

Before You Getting Started

Please check that you can follow this article now. It would be best if you thought those considerations before you getting started.

First, the iSH is still in development. You may not be able to achieve all your shell experiences or some critical tools for your works — this article written for ideation and demonstration purposes.

Second, be aware of your internet connection! This tutorial causes heavy traffic usage. Ensure that you are using a non-metered, free, unlimited Wi-Fi connection. If not, you may be overwhelmed by the invoice!

Lastly, be aware of your remain battery. This tutorial causes heavy power consumption.

Also, I recommend that you would better use the hardware keyboard instead of the built-in keyboard. It makes your workspace larger. ;-)

Looks good? Then let’s get started!

Enroll Test Flight Channel

As before I mentioned, iSH is under development stage, and this app is not available on the Apple App Store at the moment of writing. Before getting started, please install the Test Flight app first. Then go to https://ish.app/ web site and enroll in the test flight channel.

After you enrolled in the test program, download the iSH app, and start it.

Update, Upgrade Existing Packages

iSH contains the Alpine Linux distribution. So you can manage your distribution packages by the APK tool.

Let’s update the latest package information with the below command.

apk update

Then, upgrade some pre-installed packages for security purposes and fix bugs.

apk upgrade

Install Python 3, Virtual Environment and Django

Let’s install the Python 3 interpreter.

apk add python3

After installation, check the Python installed correctly.

python3 —-version

Then, upgrade the PIP (Python Package Manager) to install additional packages.

pip3 install —-upgrade pip

For using Django, you need to install the bash shell and the virtualenv Python package.

apk add bashpip3 install virtualenv

Are all things getting done? Then let’s create a virtual environment in your home directory. The virtual environment’s name is helloworld.

cd ~/virtualenv helloworldcd helloworld

Lastly, activate the virtual environment, so ensuring install Django and related dependencies only in its virtual environment, not the global scope. After activation, prompt will indicate the current virtual environment name.

source ./bin/activate
Image for post
Image for post

Create, Initialize & Run Django Web Site

Let’s install the Django framework in the virtual environment.

pip3 install django

After installation, you can use the Django-admin tool. With this tool, you can scaffold the new instance of the web site and local SQLite database (which also supported in the iSH environment.)

django-admin startproject helloworldcd ./helloworld

Current states of the local SQLite DB not synced with project database definition. You should use the migration script.

python3 ./manage.py migrate
Image for post
Image for post

Also, it would be best to protect and secure applications, and you need to create a default super administrator account before starting a web site. Run the below command and follow the dialog.

python3 ./manage.py createsuperuser
Image for post
Image for post

You can now run the Django server. Please run the below command to fire up. With — insecure switch, Django will allow any incoming connection to the server.

python3 ./manage.py runserver —-insecure 0.0.0.0:8000

You can find the Django server runs successfully on your iPad. :-D

Image for post
Image for post

Using Multitasking Feature

Essentially, you can run this tutorial on your iPhone, not only the iPad. But both environment does not support background processes. So if you run the Django server, then activate another application such as Safari or Google Chrome on top of the iSH, the iSH suspends soon. On the iPhone, because of this, your experiences of debugging the Django application not good.

I recommend that you would better use this approach on your iPad device because iPadOS supports multitasking with the split-view.

For those who are not familiar with the split-view, please look out this help document on the Apple web site. iSH already supports the split-view feature on iPad OS.

https://support.apple.com/en-us/HT207582

Then let’s make a split-view. On the left side, you can place your favorite web browser, and on the right side, you can place the activate the iSH app, which runs the Django server.

You can access the Django server through the address http://localhost:8000.

Image for post
Image for post

Voila! Also, you can access the admin page through http://localhost:8000/admin. Provide your credential what before you specified earlier step, then you will get a neat and familiar admin page!

Image for post
Image for post

The console shows logs that you correctly connected with the local server on the iPad.

Some More Tips

If you consider using this environment in earnest, you can do more things like below.

  • Install the VIM, Git (or Subversion, CVS), and SSH with your key-pair.
  • Install the TMUX for multi-tasking inside the terminal.

If you are a big fan of the Working Copy app, the FileProvider implementation in its on the way. You can track the progress and contribute to this feature at https://github.com/tbodt/ish/pull/543. :-)

Image for post
Image for post

Beyond the Windows

DevOps Engineer’s Blog

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store