[Fixed]-PhoneGap with Django Backend

19👍

That’s right, you cannot run python code on iOS or Android using PhoneGap, but there is no need to do that. Yes, you can build a native mobile application of your site using PhoneGap.

I’ll try to explain a bit how these technologies compare to each other:

  • Django is a python web framework running on a web server
  • PhoneGap is a framework for building native mobile applications using web technologies (HTML5+CSS+Javascript), the application will run on a mobile device

One common approach is to build the mobile UI with i.e. jQuery Mobile and use the Django web application to provide a RESTful API to get data to the application.

Take a look at this another question for more details.


Edit: Answer the question in the first comment

Yes, it’s possible to build a fast and well working application with these frameworks. The performance with today’s smartphones is more dependent on the quality of the implementation than i.e. jQuery mobile and Django in themselves.

Basically with PhoneGap there are three different ways for showing the content to the user:

  • server side generated pages
  • pages generated on the client side with Javascript usin data from the server, transferred in a predefined format using for example JSON
  • a combination of the previous two

This answer clarifies server-client communication and page rendering quite well.

You could use PhoneGap a bit like a constrained web browser, and basically show content directly from your server as you would when the user accesses the site with a normal web browser. But I don’t recommend this, though. This approach has many downsides to it (i.e. what happens when the user opens a link from your website leading to another website?)

To be accurate, at least in my opinion, UI written with Javascript and running inside an app built with PhoneGap is not native. Comparing native applications and PhoneGap applications is another thing, here is one take on explaining the differences.

I don’t know what kind of service you are building, but in general I’d suggest evaluating the different approaches before starting to build an application. Would a responsive mobile optimized web site do or is there real need for what an app can provide?

If you decide to build an app with PhoneGap, I’d suggest that you do it with client side Javascript and fetch the data from the Django backend with XHR requests in JSON format. There are lots of examples available in the internet.

👤lekksi

Leave a comment