Simple-todo tool in Python Django framework
This article mainly introduces the simple-todo tool in the Python Django framework. This tool is based on the open-source project in the original web. py. If you need it, refer
Origin
Simple-todo is the first example of a Chinese tutorial on web. py. Later, the Uliweb author limodou thought this tutorial was good, so he had the Uliweb version of simple-todo. Then we have the Bottle and Flask versions. This has become a FrameworksShow project. Since it is FrameworksShow, Django should never be missing.
Simple-todo: A simple todo Program
Http://simple-is-better.com/news/309
Simple Todo (Uliweb version) tutorial by @ limodou
Http://simple-is-better.com/news/312
Simple-TODO Bottle implementation edition by @ zoomquiet
Http://simple-is-better.com/news/509
Simple-TODO Flask implementation version by @ wyattwang
Http://simple-is-better.com/news/524
Operation requirements
Django >=1.3
Installation and running
Initialize the database: python manage. py syncdb
Start: python manage. py runserver
Use: Open http: // 127.0.0.1: 8000/in the browser/
Django Admin: Open http: // 127.0.0.1: 8000/admin/in the browser/
Project development records
Create a django project and app:
?
1 2 3 |
Startproject simple_todo_site django-admin.py Cd simple_todo_site/ Python manage. py startapp simpletodo |
Edit settings. py to configure databases, templates, and static files. The main configuration items are as follows:
# Note: I think django should add more default settings. These configuration changes are annoying.
DATABASES
INSTALLED_APPS
STATIC_ROOT
STATICFILES_DIRS
TEMPLATE_DIRS
Edit urls. py to add the django admin and static File url configurations.
Edit simpletodo/models. py to complete the data model:
?
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 |
Create a database:
?
1 |
Python manage. py syncdb |
Run it up and enter django admin to see first:
?
1 2 |
Python manage. py runserver # Http: // 127.0.0.1: 8000/admin/ |