本项目我们使用单独的git仓库进行管理,项目生成过程是这样的:
$ virtualenv djwebapp-blog
$ cd djwebapp-blog
$ source bin/active
$ pip install django==1.6.4
$ pip install ipython
这里些操作,用以生成一个可使用的Django开发的虚拟环境,下一步就是创建博客项目了,你们命名为djblog
,在进行本地Django项目创建之前,我们可以先到Github上创建一个名为djwebapp-blog
的项目,然后把这个空的项目clone到本址的环境中来。
我这里创建好的项目地址是:
$ git clone git@github.com:wwq0327/djwebapp-blog.git
$ cd djwebapp-blog
$ django-admin.py startproject djblog
$ ls
LICENSE README.md djblog
现在只是一个空的项目,然后我们进入到djblog
这个项目目录中,去创建一个blog
应用:
$ ./manage.py startapp blog
然后我们使用manager.py
这个管理工具,初始一下数据库:
$ ./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
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'wyatt'):
Email address: wwq0327@gmail.com
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
这里步中,初始化数据库,会在项目目录生成一个名为db.sqlite3
的数据文件。同时操作中,需要你设置一下管理员帐号的信息,这个信息很重要,后台管理的时候需帐号和密码,请记住。
到这一步,我们已经将基本的项目初始化完成了,下一步,我们需要进行一些必要的设置和一些目录的创建。