1、先创建项目
django-admin.py startproject cst04
cd cst04
django-admin.py startapp blog
2、修改F:\cst04\cst04\setting.py文件里内容
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'cst04',
'USER':'root',
'PASSWORD':'123456',
'HOST':'',
'PORT':'',
}
}
3、配置F:\cst04\blog\models.py
from django.db import models class Entry(models.Model): name=models.CharField(max_length=30) def __unicode__(self): return self.name class Blog(models.Model): name=models.CharField(max_length=30) entry=models.ForeignKey(Entry) def __unicode__(self): return self.name
4、创建数据库
5、同步数据库
pyhton manage.py syncdb
6、测试