在Python的Django框架中simple-todo工具的简单使用

yipeiwu_com6年前Python基础

缘起

simple-todo最早是web.py一个中文教程的例子。后来Uliweb的作者limodou 认为这个教程很不错,于是有了Uliweb版的simple-todo。接着又有了Bottle版和Flask版。这俨然成了一个FrameworksShow项目。既然是FrameworksShow, 那Django的总不应当缺了吧。

simple-todo: 一个简易的 todo 程序
http://simple-is-better.com/news/309

Simple Todo (Uliweb 版本) 教程 by @limodou
http://simple-is-better.com/news/312

Simple-TODO Bottle 实现版 by @zoomquiet
http://simple-is-better.com/news/509

Simple-TODO Flask实现版 by @wyattwang
http://simple-is-better.com/news/524
运行需求

Django>=1.3
安装及运行

初始化数据库: python manage.py syncdb

启动: python manage.py runserver

使用: 在浏览器中打开 http://127.0.0.1:8000/

Django Admin: 在浏览器中打开 http://127.0.0.1:8000/admin/
项目开发记录

    创建django project和app:
 
  

 django-admin.py startproject simple_todo_site
  cd simple_todo_site/
  python manage.py startapp simpletodo

    编辑settings.py完成数据库、模板、静态文件等配置,主要配置条目:

    #注:我认为django应当加更多的默认设置,这些配置改的挺烦
    DATABASES
    INSTALLED_APPS
    STATIC_ROOT
    STATICFILES_DIRS
    TEMPLATE_DIRS
    编辑urls.py把django admin和static文件url配置加上。
    编辑simpletodo/models.py,完成数据模型:

     
   

 from django.db import models
  from django.contrib import admin
   
  class Todo(models.Model):
    title = models.CharField( max_length=255)
    finished = models.IntegerField(default=0)
   
    def __unicode__(self):
      return self.title

    创建数据库:
 

  python manage.py syncdb

    跑起来,进django admin看看先:
  

 python manage.py runserver
  #http://127.0.0.1:8000/admin/

相关文章

pytorch中torch.max和Tensor.view函数用法详解

torch.max() 1. torch.max()简单来说是返回一个tensor中的最大值。 例如: >>> si=torch.randn(4,5) >&g...

Python线程池模块ThreadPoolExecutor用法分析

本文实例讲述了Python线程池模块ThreadPoolExecutor用法。分享给大家供大家参考,具体如下: python3内置的有Threadingpool和ThreadPoolEx...

python调用动态链接库的基本过程详解

python调用动态链接库的基本过程详解

动态链接库在Windows中为.dll文件,在linux中为.so文件。以linux平台为例说明python调用.so文件的使用方法。 本例中默认读者已经掌握动态链接库的生成方法,如果不...

python 输出一个两行字符的变量

今天遇到老朋友,就加了个/n 呵呵。比我的简单。 简单示例如下: >>> a='aaa\nbbb' >>> print a aaa...

python 将有序数组转换为二叉树的方法

python 将有序数组转换为二叉树的方法

题目:将[0,1,2,3,4,5,6,7,8,9,10]存储到二叉树,原数组有序,转换为二叉排序树。 二叉排序树的特点:当前节点的左子树上的所有节点都小于该节点,右子树上的所有节点都小于...