15

I am a Django developer and wanted to know if anyone has any idea of the possibilities of installing and developing on Django using an Android tablet such as the nexus 7. This seems like a reasonably powerful device, can be hooked up with a bluetooth keyboard, and has linux at the core of the OS.

So - is it possible to install Python and Django (or even Flask) on Android?

10 Answers 10

15

Yeah! its posible!, but you need install termux terminal on Android and later open the termux terminal and write:

apt-update
apt-install python
pip install django
django-admin startproject demo
cd demo
python manage.py runserver 0.0.0.0:8000

and its all, open localhost:8000 on your browser, see the picture:

enter image description here

3
  • what ide should i use for editing flies, from where i can access my demo project files. Sep 9, 2020 at 15:56
  • To be honest I don't know, but you can find one in the play store maybe, or just try to use Git maybe, not sure if that is possible Sep 14, 2020 at 17:50
  • Pydroid 3 is the best IDE on Android for editing python files. I use it along side with termux. cd to the project and runserver in termux, and open the same file in pydroid3. Whenever you hit save in pydroid3 changes are immediately reflected in termux and the server. Mar 1, 2021 at 21:50
12

We're developing PythonAnywhere to fill just this kind of niche. We tuned it to work with the iPad first. But it seems that the Nexus 7 is popular enough now that there might be enough demand to do the same thing for Android.

2
  • That's great news. I think you would have a lot of taers if you prted to android! Nov 18, 2012 at 22:56
  • And another 2 years later... Does not seem like much has changed.
    – j-i-l
    Aug 29, 2017 at 10:54
4

SL4A is a ridiculously excellent library/sdk/app for android and gives you a way to install a number of language/scripting runtimes and a thin veneer for accessing android functionality via the scripting frameworks.

It so happens that Python is an option, and I've used it with cherrypy (python framework) on Android. I haven't tried it with flask or Django but with some work it should be possible.

The app provides a way to download python, install it, and then a way to launch a python console or even just run python scripts.

http://code.google.com/p/android-scripting/

There was a downside to the python support originally, due to a silly bug/limitation in the Android SDK. This restricted the use of apk assets with _ underscore in the name. The details are faint in my mind, but I am subscribed to the issue in Android so I can follow up with the details about this issue. This would present a problem with many of the python frameworks, as underscores are part of python style.

1
  • 2
    Also, not clear why the top answer has so many votes. Cool product/service, but not answering the question. And the second top answer "install linux distro" on Android? If rooting was an option, this is a nice choice, but typically there are some constraints like space. I'm not sure that's a good general option for anyone who runs into this question.
    – truedat101
    Nov 22, 2013 at 21:01
3

One good way to accomplish a django development environment on a Nexus7 is to install a linux distro with a package manager alongside Android. Debian Kit hooks into the existing Android directories with symlinks instead of a chroot environment.

With that you can install Debian or Ubuntu and use apt-get and pip to install git, virtualenv, and all the packages and libraries you need to set up your development environment as you would on a desktop. You can write your code in DroidEdit, run the django development server in an Android terminal through ssh to localhost, and test your app right there in the browser on Android.

1
  • ... agree on that. I've installed debian on my nexus4/7 and running apache/mod_wsgi/virtualenv/django + postgesql + cups. Performs much better then the cubox.
    – st0ne
    Aug 22, 2013 at 21:24
2

I could run on my Tablet (android) and smartphone (android) following the procedure below:

  • Install "GNUroot Debian" app;
  • Open "GNUroot Debian" app;
  • Run these commands:

    apt-get update
    apt-get install python3
    apt-get install python3-setuptools
    easy_install3 pip
    pip install django
    django-admin startproject demo
    cd demo
    python manage.py runserver
    
2

QPython suports Django on Android. I am running it on my android device.

2

Do you want this? :

p.s: I confess that article's original source is me. But isn't it nice? :)

1
  • 1
    Whilst this link may answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Link-only answers can become invalid if the linked page changes. Jun 22, 2018 at 9:09
1

Well if your end goal is to develop Web applications and host host them on your Android and since you had flask there why not give bottle.py a shot. It's just one file that you copy into your sl4a scripts folder and voila. Bottle is minimalist and near similar to flask. No rooting or Unix environments required.

1

Install termux terminal on Android and later open the termux terminal and write:

pkg install python
pip install django
django-admin startproject demo
vim demo/demo/settings.py

In settings.py

ALLOWED_HOSTS = ['*']

After save the settings.py and

python manage.py runserver 0.0.0.0:8000

and its all, open localhost:8000 on your browser

0

If you are developing an android app and you don't want to use Java, you might want to consider Kivy http://kivy.org/#home

If you are talking about having a web server running on Android and then running your django web app on that web server itself, there's a duplicate answer here - Web Server for Android

2
  • 1
    My question is more about the possibilities of using the terminal in android and setting up Django with it's devserver and any python packages. This is not for developing android apps per se, more for developing Django apps as though I was working in linux. Basically using the tablet as a highly portable dev environment. Nov 18, 2012 at 21:21
  • @Darwin Tech: There is a lot more to Android than just Linux with knobs on. Python runs alongside a Dalvik VM and communicates with SL4A (via JSON), which communicates with the Android runtime. It is not really a "highly portable dev environment".
    – cdarke
    Nov 18, 2012 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.