QNA > C > Can You Write Mobile Apps In Python/Django?

Can you write mobile apps in Python/Django?

Yes you can

Requirements

Android SDK tools

Download, the command line tools, for example: sdk-tools-linux-3859397.zip and follow:

  1. unzip sdk-tools-linux-3859397.zip -d android_sdk 

cd android_sdk/tools/bin

  1. chmod a+x sdkmanager avdmanager 
  2. ./sdkmanager "platforms;android-21" 
  3. ./sdkmanager --update 

Now you must have android_sdk/platforms/android-21 in your system, take note about android_sdk absolute path.

Crystax NDK

We are using Python3, so, we need Crystax NDK and NOT the official. [python-for-android now supports Python 3

APKs]. Download it and take note about their absolute path.

Python-for-Android

We need the last release of Python-for-android

  1. git clone kivy/python-for-android 
  2. cd python-for-android 
  3. sudo python http://setup.py install 

We need install the main python module, just with:

  1. `pip install djangoforandroid 

Configuration

Installed apps

Add djangoforandroid.builder to your INSTALLED_APPS setting.

  1. INSTALLED_APPS = ( 
  2. ... 
  3. 'djangoforandroid.builder', 
  4. 'djangoforandroid.mdl', #optional, for mdl support 
  5. 'djangoforandroid.d4a', #optional, for urls support 

If you want use Material Design Lite in your app then you would like add djangoforandroid.mdl to IN-

STALLED_APPS apps and follow this tutorial.

Static files

Django for Android must run internally the collectstatic command, STATIC_ROOT must be defined.

  1. STATIC_ROOT = os.path.join(BASE_DIR, 'apk')``` 

Remember add your statics files too.

  1. STATICFILES_DIRS = [ 
  2. os.path.join(BASE_DIR, "static"), 

Urls

Add this to http://urls.py configuration for extra features like: URIs.

  1. url(r'^d4a/', include('djangoforandroid.d4a.urls')), 

Lazy way

Django for Android include a set of preloaded libraries like: mdl, jquery, hammer... All this can be impoted adding

the following line in your base html template.

  1. {% load staticfiles %} 
  2. ... 
  3. {% include "djangoforandroid/mdl.html" %} 

Di Landmeier Vaibhav

I portatili Microsoft Surface sono degni di essere acquistati come ricondizionati? :: Perché i portatili Surface sono così costosi?
Link utili