欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2/Agda, C++/Lisp/Haskell
Django
来自开放百科 - 灰狐
(版本间的差异)
第15行: | 第15行: | ||
python manage.py runserver | python manage.py runserver | ||
http://localhost:8000 | http://localhost:8000 | ||
+ | |||
+ | 创建一个poll应用 | ||
+ | python manage.py startapp polls | ||
+ | vi polls/models.py | ||
+ | from django.db import models | ||
+ | |||
+ | class Poll(models.Model): | ||
+ | question = models.CharField(maxlength=200) | ||
+ | pub_date = models.DateTimeField('date published') | ||
+ | |||
+ | class Choice(models.Model): | ||
+ | poll = models.ForeignKey(Poll) | ||
+ | choice = models.CharField(maxlength=200) | ||
+ | votes = models.IntegerField() | ||
+ | |||
+ | vi polls/settings.py | ||
+ | INSTALLED_APPS = ( | ||
+ | 'django.contrib.auth', | ||
+ | 'django.contrib.contenttypes', | ||
+ | 'django.contrib.sessions', | ||
+ | 'django.contrib.sites', | ||
+ | 'mysite.polls' | ||
+ | ) | ||
+ | 创建数据库 | ||
+ | python manage.py sql polls |
2006年9月2日 (六) 11:33的版本
Django: The Web framework for perfectionists with deadlines
安装指南
First, download Django-0.95.tar.gz. Then:
tar xzvf Django-0.95.tar.gz cd Django-0.95 sudo python setup.py install cd /var/www django-admin.py startproject mysite cd mysite python manage.py runserver http://localhost:8000
创建一个poll应用
python manage.py startapp polls vi polls/models.py from django.db import models
class Poll(models.Model): question = models.CharField(maxlength=200) pub_date = models.DateTimeField('date published')
class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(maxlength=200) votes = models.IntegerField()
vi polls/settings.py INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'mysite.polls' )
创建数据库
python manage.py sql polls
分享您的观点