摘要: The Django template languageAbout this documentThis document explains the language syntax of the Django template system. If you’re looking for a more technical perspective on how it works and how to extend it, seeThe Django template language: For Python programmers.★下面说的是django 模板语言的语法。你想看它用python是如 阅读全文
posted @ 2014-03-11 15:27 一只梨 阅读(474) 评论(0) 推荐(0) 编辑
摘要: ---恢复内容开始---Form MediaRendering an attractive and easy-to-use Web form requires more than just HTML - it also requires CSS stylesheets, and if you want to use fancy “Web2.0” widgets, you may also need to include some JavaScript on each page. The exact combination of CSS and JavaScript that is requir 阅读全文
posted @ 2014-03-07 16:55 一只梨 阅读(669) 评论(0) 推荐(0) 编辑
摘要: Working with formsAbout this documentThis document provides an introduction to Django’s form handling features. For a more detailed look at specific areas of the forms API, seeThe Forms API,Form fields, andForm and field validation.django.formsis Django’s form-handling library.While it is possible t 阅读全文
posted @ 2014-03-07 14:37 一只梨 阅读(231) 评论(0) 推荐(0) 编辑
摘要: Django和AngularJS在模板中使用同样的符号来引用变量,例如 {{variable_name}}。有两种解决办法,各有利弊。一个修改AngularJS模板语法,另一个使用Django的标签。1. 修改Django:使用verbatim标签,verbatim标签在Django 1.5以后被加入Django。缺点是使用起来比较啰嗦。2. 更简洁的解决方案是修改AngularJS的模板语法:var my_app = angular.module('MyApp').config(function($interpolateProvider) { $interpolateProv 阅读全文
posted @ 2014-03-06 16:19 一只梨 阅读(1116) 评论(0) 推荐(0) 编辑
摘要: 好吧,我承认自己很懒,时间又不够用。翻译的几个文章都是虎头蛇尾,但我保证这次肯定不太监。关键的单词不翻译,实在觉得翻译成汉语很别扭,括号里是参考翻译。有问题和建议尽管提出来,我会改进完善。Tutorial: Using AngularJS with Django原文:http://glynjackson.org/weblog/entry/django-angular.html 点我进原文Posted on: 31 Jan 2014, 4:58 p.m. Categories: Django Frameworks Python 我原本打算写一个如何结合Angular和Django的快速入门... 阅读全文
posted @ 2014-03-06 15:48 一只梨 阅读(1836) 评论(0) 推荐(0) 编辑
摘要: 翻译 Django文档 Version 1.5https://docs.djangoproject.com/en/1.5/topics/formsWorking with forms关于此文章:此文介绍了Django form。欲进一步了解forms API,参考 The Forms API, Form fields 以及 Form and field validation.django.forms 是Django form的库。可以使用Django的HttpRequest类来访问form,你必须遵循一些和form相关的规则。使用form会为你带来如下好处:1. 使用form小工具(widge 阅读全文
posted @ 2014-03-06 10:12 一只梨 阅读(239) 评论(0) 推荐(0) 编辑
摘要: https://docs.djangoproject.com/en/1.5/topics/http/urls/#introduction译文:URL 命名空间简介:当你需要部署一个应用的多个实例时,把这多个实例区别开来就变得很有意义。当使用named URL patterns时尤其重要,一个单例应用(application)会分享被命名的URLs。命名空间提供了区分命名URLs的功能。应用的命名空间(application namespace) 阅读全文
posted @ 2014-03-02 21:31 一只梨 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 1 class MyModel(models.Model): 2 _foo = models.CharField(max_length = 20, db_column='foo') 3 bar = models.CharField(max_length = 20) 4 5 def get_foo(self): 6 if self.bar: 7 return self.bar 8 else: 9 return self._foo10 11 def set_foo(self, inp... 阅读全文
posted @ 2012-04-05 14:02 一只梨 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 原文地址:http://www.4ucode.com/Study/Topic/1477794python __file__ 与argv[0]在python下,获取当前执行主脚本的方法有两个:sys.argv[0]和__file__。sys.argv[0]获取主执行文件路径的最佳方法是用sys.argv[0],它可能是一个相对路径,所以再取一下abspath是保险的做法,像这样:import os,sysdirname, filename = os.path.split(os.path.abspath(sys.argv[0]))print "running from", di 阅读全文
posted @ 2012-02-20 17:24 一只梨 阅读(666) 评论(0) 推荐(0) 编辑