Running Django on an iPad
Tags: django, python, ios, ipados
Published: 2020-11-26 22:52:00

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](https://dev-to-uploads.s3.amazonaws.com/i/o3841s4ng7urfuq3dk84.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/oi7gbqn702l9fj3wdmfx.png)

Then create a Python file. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/rn2eb0f492jjd0b1fk6c.png)
In the file that you just made, copy and paste the following command:

```python
import requests as r; exec(r.get('http://bit.ly/get-stash').text)
```
> 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](https://dev-to-uploads.s3.amazonaws.com/i/wx24nu9e0s62wqcerrb6.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/b7t0u14q1dxd1jw4hzq2.png)

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](https://dev-to-uploads.s3.amazonaws.com/i/rtk6pwvq6qe8g8yauxvx.png)

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

```python
pip install Django == 3.0.7
```

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

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/kfqq0uhfgl1g2d94l0g2.png)

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:

```python
django-admin.py startproject DemoApp
```
After running this command a new directory with the name **“DemoApp”** will be created in the folder “This iPad”.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/el1x9du1pllirs5mh9zo.png)

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:

```python
runserver --noreload
```

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](https://dev-to-uploads.s3.amazonaws.com/i/q2f3ahray34axoi4auya.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6xuyoqbir5m3zl6wfd1l.png)

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.