很好的学习地址:
http://django-chinese-docs-16.readthedocs.org/en/latest/intro/tutorial01.html
Python 3.3 +Django 1.6
Python 3.3和低版本的搭建有点不同,开始是各种错误
设置一下PATH:
c:\Python32\Scripts
创建一个项目 FirstDJProject:
python django-admin.py startproject FirstDJProject
(如果报错直接用django-admin.py的绝对路径)
创建一个应用 blog:
python manage.py startapp blog
(如有错误同上)
在blog->models.py 添加代码:
class BlogPost(models.Model):
body = models.TextField()
在FirstDJProject->settings.py
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog', #这里用了FristDJProject.blog报错了,估计是python3.x的搜索在当前目录开始
)
输入:
python manage.py syncdb
Creating tables ...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table bog_blogpost
运行成功