DEV Community

Juan De los santos
Juan De los santos

Posted on

Running Django on an iPad

A few months ago I just convinced myself about not needing a PC on my daily basis, so since then I’ve been using my iPad for all the work-related stuff that I have to do such as interviews to QA candidates, create test cases and status reports and even coding for personal projects, and about this last one is what I want to tell you on this article.

I started learning Django a couple of weeks before I started this challenge, but when I decided to put my knowledge into practice I couldn’t find a bug-less article online that helped me to set that up on the iPad. So, after a little research on a couple of forums I kind of merge that knowledge together and I was able to get it working properly and without any issues (So far..), let’s jump into how I made it.

Here are the things we are going to need:

Pythonista-> A python IDE that will allow us to read, write and execute our code.

StaSH-> Is a Bash-like shell for Pythonista that will enable us to use the pip commands.

The first thing we are going to do is download “Pythonista 3” from the Apple Store, this app cost $9.99 and by the time I’m writing this article it is the only app that supports Django and other advanced development features.

Alt Text

Once you have downloaded the app, we need to install StaSH, this is because Pythonista does not support the pip command natively and we'll need that to install Django.

To install StaSH, launch Pythonista, click on the (+) in the bottom-left of the screen.

Alt Text

Then create a Python file.

Alt Text
In the file that you just made, copy and paste the following command:



import requests as r; exec(r.get('http://bit.ly/get-stash').text)


Enter fullscreen mode Exit fullscreen mode

I recommend that you copy and paste the commands because sometimes the autocorrection just makes the execution to fail even if it looks "the same".

After adding the command, click on the Play button on the top of the screen, if the command is ok then Pythonista will start to download StaSH.

Alt Text

When the download is completed, re-start Pythonista by closing the app (don’t let the app in background) and open it again. To validate that the installation was successful, inside Pythonista go to “This iPad”, and there should be a file named launch_stash.py.

Alt Text

The last thing at this point is to download Django and create a test project; For that, Open the file launch_stash.py and click on the play button, this action will launch the StaSH shell where we can use the pip command.

Alt Text

On the StaSH shell, type the following command to download Django and hit “return” on your keyboard.



pip install Django == 3.0.7


Enter fullscreen mode Exit fullscreen mode

This will start downloading the Django version that you specified and will install it on Pythonista.

Alt Text

Once the installation process is completed, re-start Pythonista again.

Now to create and start our first Django project on an iPad, launch the staSH shell, and type or copy the following command:



django-admin.py startproject DemoApp


Enter fullscreen mode Exit fullscreen mode

After running this command a new directory with the name “DemoApp” will be created in the folder “This iPad”.

Alt Text

Finally to run our “DemoApp” project, re-start Pythonista (yes, again), go inside the project directory, open the “manage.py” file, hold the play button on the top of the screen and on the new field displayed paste the following code and hit the “Run” action on the top-right of the screen:



runserver --noreload


Enter fullscreen mode Exit fullscreen mode

And finally, after that action Pythonista will launch the local server with the project that we just made and now you can type the IP for your local server in your browser and you will see the Django app running.

Alt Text

Alt Text

The only complaint I have about this tool (Pythonista), is that I have to re-start the app after every installation, but that’s not a big deal to me.

I really hope that the migration to ARM's CPUs on the Mac line-up finally brings more powerful tools to the iPads in the next couple years so it can be a real substitute of a PC, but currently there are certain limitations about what you can do on these devices.

Have you used an iPad or Tablet as your main work-related device? if so, let me know how was your experience or let me know if there's another tool that you want me to try on an iPad, or if you are interested in what other productivity apps I've used on my daily basis.

Top comments (8)

Collapse
 
bethanybeachbum profile image
Mark Brown

When I run “runserver —no reload” I get the following error:
CommandError: "—-noreload" is not a valid port number or address:port pair.
Any chance you help me figure out my proble?
Thank you for any assistance

Collapse
 
ozrhodes profile image
Oz Rhodes

Try copy and paste of the
runserver —noreload

The keyboard entry sometimes make the double dash a single long dash.

Hope that helps
Oz

Collapse
 
thorstenhirsch profile image
Thorsten Hirsch

It's not supposed to work.

I don't say that it's impossible - you even proved that with certain requirements it might be possible to do part of your work with specific apps. But iOS devices are not supposed to be an IT professional's main work device. The introduction of tablets (or smartphones) marked a paradigm shift in the computer world. It was not longer the goal to build the best multi-purpose computer (PC or Mac), instead the new goal was (and still is) to build the best consumer device. And consumers don't need multi-purpose. So the operating systems of these devices have some trade-offs:

  • they heavily restrict user access to the system
  • they even restrict the installed software's access to the system (sandboxed apps can't even talk to each other)
  • and most of them restrict the way you're allowed to install software (some even let you only install software that has been certified by the hardware vendor, for which he even charges a huge fee)

For a consumer these trade-offs are the base for secure devices (because it's harder to install malware and viruses) and nearly zero system maintenance work. However the trade-offs are the opposite of what a Django developer (or any other developer) requires:

  • access to the system, in order to install any software framework and libraries a developer needs (even the ones he wrote him-/herself)
  • use different software applications together, like a linter in an IDE or npm in docker, even granting them shared access to files & directories

The only reasonable use of these consumer devices in relation to my work I can imagine is to use them as dumb terminals in order to access a multi-purpose computer. That doesn't have to be one's own computer. More and more developers seem to be pretty happy to use cloud-based development environments... so in the end we might even see more IT professionals using them. But we won't see these consumer devices being used as development environments, because it will always be a struggle trying to undo the restrictions Apple has implemented in the core of iOS.

Collapse
 
therealdarkmage profile image
darkmage

This doesn't apply to Android's ecosystem :)

Collapse
 
simon_says profile image
Simon Pastor

Hi @jjsantos ,

do you still use Pythonista + Django?
what can o tell about you experience with your codding experience on Ipad? I´m about to try it.. what advise could you give us( ipad owners) on it, based on your experience ?

have your tried blink ?

how about Replit ?

or any other coding solution for python + (frameworks... like Django or Flask) ?

best regards

Collapse
 
sepyrt profile image
Dimitris R

Wow, excellent! Can you also install docker? :)

Collapse
 
thorstenhirsch profile image
Thorsten Hirsch

lol

Some comments may only be visible to logged-in visitors. Sign in to view all comments.