在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/

相关文章

TensorFlow Session会话控制&Variable变量详解

TensorFlow Session会话控制&Variable变量详解

这篇文章主要讲TensorFlow中的Session的用法以及Variable。 Session会话控制 Session是TensorFlow为了控制和输出文件的执行语句,运行sessi...

对Python中TKinter模块中的Label组件实例详解

对Python中TKinter模块中的Label组件实例详解

Python2.7.4 OS—W7x86 1. 简介 Label用于在指定的窗口中显示文本和图像。最终呈现出的Label是由背景和前景叠加构成的内容。 Label组件定义函数:Label...

python调用java的jar包方法

如下所示: from jpype import * jvmPath = getDefaultJVMPath() jars = ["./Firstmaven-1.0-SNAPSHO...

django 控制页面跳转的例子

如下所示: def delEquipment(request, delip): print delip ip=delip conn= MySQLdb.connect(...

在pytorch 中计算精度、回归率、F1 score等指标的实例

pytorch中训练完网络后,需要对学习的结果进行测试。官网上例程用的方法统统都是正确率,使用的是torch.eq()这个函数。 但是为了更精细的评价结果,我们还需要计算其他各个指标。在...