1、创建自己的app
进入新建的blog工程目录,执行其下面的manage.py来创建polls应用,命令为:
python manage.py startapp polls
2、定义app的models
Each model is represented by a class that subclasses django.db.models.Model.
Each model has a number of class variables, each of which represents a database field in the model.
for example:
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
3、安装app
Edit the settings.py file, and change the INSTALLED_APPS setting to include the string 'polls'.
4、创建app需要的表
4.1、生成app需要的表创建sql执行命令: python manage.py sql polls
4.2、在数据库中执行上面生成的sql语句。
5、add __unicode__() methods to your models
We use __unicode__() here because Django models deal with Unicode by default.
All data stored in your database is converted to Unicode when it's returned.
Django models have a default __str__() method that calls __unicode__()
and converts the result to a UTF-8 bytestring.
This means that unicode(p) will return a Unicode string,
and str(p) will return a normal string, with characters encoded as UTF-8.
6、Make the poll app modifiable in the admin
Open polls/admin.py,and edit it to look like this:
from polls.models import Poll
admin.site.register(Poll)
如果想自己定义管理界面,那么自定义一个类,并重新注册,如:
class PollAdmin(admin.ModelAdmin):
fields = ['pub_date', 'question']
admin.site.register(Poll, PollAdmin)
7、Customizing your project’s templates
by default, Django automatically looks for a templates/ subdirectory within each application package
8、修改工程的urls.py
添加内容: url(r'^polls/', include('polls.urls', namespace="polls")),
9、中间用到的文件可以参考django的官方网站https://docs.djangoproject.com/en/1.6/intro/tutorial03/

bae3.0第四步 第一个polls系统的更多相关文章

  1. petshop4.0 具体解释之中的一个(系统架构设计)

    前言:PetShop是一个范例,微软用它来展示.Net企业系统开发的能力.业界有很多.Net与J2EE之争,很多数据是从微软的PetShop和Sun的PetStore而来.这样的争论不可避免带有浓厚的 ...

  2. bae3.0第三步 添加默认管理后台模块和mysql库

    1.创建数据库 先在本地的mysql数据库中创建数据库db_blog,执行python manage.py syncdb来创建表. 然后将数据库中的表导入到bae上的数据库中.2.配置数据库 修改项目 ...

  3. ElasticSearch第四步-查询详解

    ElasticSearch系列学习 ElasticSearch第一步-环境配置 ElasticSearch第二步-CRUD之Sense ElasticSearch第三步-中文分词 ElasticSea ...

  4. [原创]css3简单几步画一个乾坤图

    效果如上,鼠标移上去会有动画. 代码如下非常简单: <html> <head> <style> .outer{height:100px;width:200px;bo ...

  5. Ajax发送异步请求(四步操作)

    1.第一步(得到XMLHttpRequest) *ajax其实只需要学习一个对象:XMLHttpRequest,如果掌握了它,就掌握了ajax!! *得到XMLHttpRequest >大多数浏 ...

  6. Linux强化论:15步打造一个安全的Linux服务器

    Linux强化论:15步打造一个安全的Linux服务器 Alpha_h4ck2016-11-30共28761人围观 ,发现 8 个不明物体专题系统安全 可能大多数人都觉得Linux是安全的吧?但我要告 ...

  7. BAE3.0上的java+tomcat代码发布

    ---------------------------------2016/01/25更新-------------------------------------- 最近两天去百度开放云,发现它再也 ...

  8. 文件下载(只需要简单的四步),Java中都通用

    我们就直接切入主题啦,文件下载只需要四步: 1.设置文件ContentType类型 2.设置文件头 3.通过response获取ServletOutputStream对象(out) 4.写到输出流(o ...

  9. 四步完成ajax的使用

    什么是ajax? ajax(异步javascript xml) 能够刷新局部网页数据而不是重新加载整个网页. 如何使用ajax? 第一步,创建xmlhttprequest对象,var xmlhttp ...

随机推荐

  1. 【Head First Servlets and JSP】笔记11:cookie

    容器如何知道客户是谁?(这并不是HTTP能实现的!IP地址不能唯一的标识用户,另外,非必要不采用HTTPS 继续mark孤傲苍狼的博客,百科全书 cookie——Header——字典——键值对—— 延 ...

  2. Java中的HashMap

    今天到中关村软件园面试被问到Java中HashMap的存值原理,瞬间无言已对,回答用了一个数组,然后沉默,面试官说,一次的面试失败不算什么,之后...... 1.关于hashCode hashCode ...

  3. Java中系统时间的获取_currentTimeMillis()函数应用解读

    快速解读 System.currentTimeMillis()+time*1000) 的含义 一.时间的单位转换 1秒=1000毫秒(ms) 1毫秒=1/1,000秒(s)1秒=1,000,000 微 ...

  4. linux开发应用程序到运行的过程

    1.给linux配置交叉编译环境 2.在windows下使用source insight写程序,一共有m个h文件,n个c文件,k个main函数 3.将源代码放在linux里 4.在源代码文件夹里新建m ...

  5. Pandas标记删除重复记录

    Pandas提供了duplicated.Index.duplicated.drop_duplicates函数来标记及删除重复记录 duplicated函数用于标记Series中的值.DataFrame ...

  6. linux环境下的python安装过程(含setuptools)

    这里我不想采用诸如ubuntu下的apt-get install方式进行python的安装,而是在linux下采用源码包的方式进行python的安装. 一.下载python源码包 打开ubuntu下的 ...

  7. freemarker日志实现过程分析

    freemarker有自己的log类,这是一个抽象类,具体的日志打印委托给classpath里面合适的日志jar包来执行,寻找合适日志jar的查找顺序是:Apache Log4J, Apache Av ...

  8. How to Delete using INNER JOIN with SQL Server?

    https://stackoverflow.com/questions/16481379/how-to-delete-using-inner-join-with-sql-server You need ...

  9. UVA 11525 Permutation (树状数组+YY)

    题意:给你k个数Si,然后给你一个等式   H= ∑  Si ∗ (K − i)!  (i=(1->k)且0 ≤ Si ≤ K − i). 叫你求出第H个全排列 其实这是一个康托展开:X=a[n ...

  10. iOS系统声音服务(System Sound Services)

    系统声音服务(System Sound Services)提供了一个接口,用于播放不超过30秒的声音.它支持的文件格式有限,具体地说只有CAF.AIF和使用PCM或IMA/ADPCM数据的WAV文件. ...