PhoneGap与Django后端 [英] PhoneGap with Django Backend

查看:96
本文介绍了PhoneGap与Django后端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个使用django的Web应用程序。

I'm working on a web application that uses django.

我想使用手机间隙为ios / android创建一个网站的本机应用程序。

I would like to create a native application of the site for ios / android using phone gap.

这是否可能?由于我理解本机设备不能解释python代码。

Is this possible? As I understand native devices cannot interpret python code.

这是项目的早期,如果证明太困难,我可以去一个不同的框架ie.e backbone.js。

It is early in the project and if it proves too difficult I may go with a different framework I.e backbone.js.

任何想法/经验?

推荐答案

在iOS或Android上使用PhoneGap运行python代码,但没有必要这样做。是的,您可以使用PhoneGap构建您的网站的本机移动应用程序。

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是在网络服务器上运行的python网络框架

  • PhoneGap是一个用于构建本机移动应用程序的框架应用程序将在移动设备上运行

一种常见的方法是构建移动UI即 jQuery Mobile ,并使用Django网络应用程序提供 RESTful API 来获取应用程序的数据。

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.

查看这是另一个问题,了解更多详情。

编辑:回答第一个注释中的问题

Answer the question in the first comment

是的,可以使用这些框架构建快速,今天的智能手机的性能更多地取决于实现的质量,比如jQuery mobile和Django本身。

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.

基本上使用PhoneGap有三种不同的方式向用户显示内容:

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


  • 服务器端生成的网页

  • 在客户端使用Javascript生成的网页使用来自服务器的数据,以预定义的格式使用例如 JSON

  • 前两个的组合

此回答明确了服务器 - 客户端通信和页面呈现。

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

您可以使用PhoneGap有点像受限制的网络浏览器,并且基本上直接从您的服务器显示内容,就像当用户使用普通的网络浏览器访问网站时。 但我不推荐这,但。这种方法有许多缺点(例如,当用户打开从您的网站到另一个网站的链接时会发生什么?)

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?)

为了准确,至少在我看来,使用Javascript编写的UI和运行在使用PhoneGap构建的应用程序中的UI不是本机的。比较本机应用程序和PhoneGap应用程序是另一回事,这里是一个解释差异

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?

如果你决定使用PhoneGap构建一个应用程序,我建议你使用客户端Javascript做它,并从JSON格式的XHR请求从Django后端获取数据。有很多示例可用互联网。

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.

这篇关于PhoneGap与Django后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆