python:
https://www.djangoproject.com --教程
pip --python的包管理器 sudo apt-get install python-pip
sudo pip install django
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2.进入mysite
python manage.py migrate
3.python manage.py runserver
4.python manage.py runserver 0.0.0.0:8000
5.python manage.py startapp polls(poll:投票)
6.gedit polls/models.py
model.py
***********************************************************
from django.db import models
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question_text
class Choice(models.Model):
question = models.ForeignKey(Question)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __unicode__(self):
return self.choice_text
# Create your models here.
***********************************************************
7.python manage.py makemigrations polls
8.python manage.py sqlmigrate polls 0001
9.python manage.py migrate
10.gedit polls/models.py
添加__str__/__unicode__ 用于显示
11.python manage.py createsuperuser
用来创建管理帐号
12.gedit polls/admin.py
admin.py
**********************************************************
from django.contrib import admin
# Register your models here.
from polls.models import Question
admin.site.register(Question)
**********************************************************
13.python manage.py runserver
打开网址/admin
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
---Question------------
1|去哪儿玩儿?|2014.09.18
2|哪儿好玩儿?|2014.09.20
-----------------------
---Choice--------------
1|1|清华大学|0|
2|1|鸟巢|0|
3|1|香山|0|
4|2|圆明园|0|
5|2|颐和园|0|
6|2|香山|0|
sqlite3 +数据库名 进入数据库
./quit --退出