且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用jQuery Mobile,Django和Phonegap构建移动应用程序

更新时间:2023-02-26 22:19:10

我个人创建了多个本地应用程序JqueryMobile作为我的前端 - Django作为服务器端 - 和phonegap本地包装到一个itunes存储应用程序。这真的是一个伟大的技术组合,如果正确地 - 可以产生一个快速的本机应用程序。

I personally have created multiple native apps with JqueryMobile as my frontend - Django as the server side - and phonegap to natively wrap into a itunes store application. It's really a great combination of technologies that - if done correctly - can yield a fast native application.

首先,你应该看看Tastypie。 Tastypie是一个非常简单的方法来创建一个即时的RESful API,可以发送JSON数据到javascript / JQuery。它是一个Django应用程序,它是非常pythonic(很多容易的类/方法覆盖 - 一切都是透明的)。

First of all you should look into Tastypie. Tastypie is a really easy way to create an instant RESful API that can send JSON data to javascript/JQuery. Its a Django app and it is very pythonic (plenty of easy class/method overrides - everything is transparent).

数据传输的流程看起来像这样: / p>

The flow of data transfer would look something like this:


  1. 使用jquery.ajax函数或getJSON函数从指定的URL获取/ post / put JSON数据。

  1. Use a jquery.ajax function or a getJSON function to get/post/put JSON data from a specified URL.

此网址是从您的模型创建的tastypie API。它可能看起来像/ api / vi / blogs / all /

This URL is the tastypie API created from your Models. it could look like /api/vi/blogs/all/

现在你的前端有Json的JSON数据 - 你可以做任何你想要的 -

Now you have JSON data in your frontend with Jquery - you can do whatever you want with it - fill in a table - work with forms - etc.

首先查看一些Jquery / Jquery移动ajax函数,如何使用JSON在前端与Jquery库。其次,熟悉将JSON发送回Django视图(解析数据并将其保存到数据库)。然后深入了解JQuery Mobile用户界面的细节以及使其与PhoneGap配合使用的步骤。

First Check out some Jquery/Jquery mobile ajax functions and how to work with JSON on the frontend with the Jquery library. Secondly get familiar with sending JSON back to a Django view (parsing the data and saving it to the database). Then dive into the specifics of JQuery Mobile User Interface and the steps to get it working well with PhoneGap.