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

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

问题描述

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



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



这是可能吗?据了解,本机设备无法解释python代码。



在项目的早期,如果证明太难了,我可能会用不同的框架I.e backbone.js去。



任何想法/经验?

解决方案

没错,在iOS或Android上使用PhoneGap运行python代码,但不需要这样做。是的,您可以使用PhoneGap构建您的网站的原生移动应用程序。



我将尝试解释一下这些技术如何相互比较:




  • Django是在网络服务器上运行的一个python web框架

  • PhoneGap是一个框架,用于构建使用网络技术(HTML5 + CSS + Javascript),应用程序将在移动设备上运行



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



查看这是另一个问题更多的细节。






编辑:在第一条评论中回答问题



是的,可以建立一个快速和这些框架的良好的工作应用程序。今天的智能手机的表现更多地取决于实现的质量,而不是jQuery mobile和Django本身。



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




  • 服务器端生成的页面

  • 在客户端生成的页面上的Javascript使用来自服务器的数据,使用例如 JSON

  • 前两个组合



这个答案澄清了服务器客户端的通信和页面呈现的良好效果。 p>

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



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



我不知道你正在建立什么样的服务,但一般来说,我建议先评估不同的方法开始构建应用程序。一个敏感的移动优化网站是做还是真的需要一个应用程序可以提供什么?



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


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

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

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

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

Any thoughts / experiences?

解决方案

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.

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

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