iOS app with Django iOS app with Django django django

iOS app with Django


I am currently working on an iOS app for iPhone, with Django / Tastypie in the backend. We do both 1 and 2. The resources are offered REST-style (after auth) via Tastypie, and any custom function calls (for example, creating a new user) are handled by views.py at various REST endpoints, which returns JSON.


When you can you should try to use a common way of doing something instead of reinventing the wheel. Given that, REST is a standard style of software architecture for distributed systems and it works very well when you work with entities/objects.

If you have an API where you interact with entities, it is recommended to use REST interfaces. On python you have Tastypie or the newer Django Rest Framework that does almost all the work. As you propose in 2)

If you have an API where you interact with services, like a login, then you should build an RPC service, basically a function with remote access as you explain on 1).

Normally you will need both ways on a robust application. And YES, it is possible to do that. I agree with @sampson-chen, we are doing the same. We have a REST interface with tastypie, and other methods are done with custom RPC services.

The performance in our case is still good, but mostly depends on the methods you call inside your services, for example, a DB query. You have a lot of ways to improve speed, for example using Celery to queue heavy jobs.

Hope it helps.


REST APIs, while very useful, limit you to GET, POST, PUT, DELETE actions, which are performed upon resources. This can make it difficult to express other action types, such as sending an email. There are a few ways I've found to handle this within django/tastypie:

  1. Issue a PUT/PATCH request on an existing resource, setting a flag that lets your backend know to trigger an action. Detecting if a flag was set can be done inside post_save signal handlers (use django-model-utils FieldTracker to see if a field was changed from False to True); this also helps make sure your application logic works the same outside your REST API (such as changes via the admin site, a celery task, an HTML based view, or the Python shell).

  2. Create a non-ORM Resource (e.g. /api/v1/email/) and override the post_list() method, calling your function there.

  3. As mentioned elsewhere, create a subordinate resource (/api/v1/myresource/send/).