在Python的Django架構中simple-todo工具的簡單使用

來源:互聯網
上載者:User

在Python的Django架構中simple-todo工具的簡單使用

   這篇文章主要介紹了在Python的Django架構中simple-todo工具的簡單使用,該工具基於原web.py中的開源項目,需要的朋友可以參考下

  緣起

  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:

  ?

1

2

3

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,完成資料模型:

  ?

1

2

3

4

5

6

7

8

9

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

  建立資料庫:

  ?

1

python manage.py syncdb

  跑起來,進django admin看看先:

  ?

1

2

python manage.py runserver

#http://127.0.0.1:8000/admin/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.