Windows下配置Django

20 Comments

这两天在跟小钟同学一起开发新版讲座网,我负责前台,小钟同学负责后台,由于前台页面时常做修改,因此会加大小钟同学工作量,所以决定用SVN同步开发。

后台是Pyhon写的,用的Django框架,因此,就需要本地配置Django环境,以前没有接触过Python,因此配置的过程可谓是艰辛痛苦,问题主要出在Mysql for Python部分,经过1天的折腾终于修成正果,分享一下:

Step 1. 安装Python,这个不用多说,msi一路Next,这里我安装在 “D:\Python”目录下。

D:\Python

D:\Python\Scripts

添加到系统环境变量Path中去。

 

Step 2. 下载Django,解压到任意目录,在Django目录下执行 :

python setup.py install

(Django将被安装到Python目录下site-packages目录)

将以下目录添加到环境变量中去

D:\Python\Lib\site-packages\django

Step 3. 安装两个必备工具,很简单,不多说

setuptools(安装库时需要)  http://pypi.python.org/pypi/setuptools#downloads

Python Imaging Library  (图像处理库)    http://www.pythonware.com/products/pil/

 

Step 4. 安装Mysql http://www.mysql.com/downloads/mysql/

 

Step 5. 安装Mysql for Python,虽然Mysql for Python的作者在Readme里说明自己不玩windows,懒得整安装包,网上还是有大牛站出来,做了exe的安装包,为我等节约生命,猛击下载: http://www.codegood.com/downloads

直接next安装即可。

(以下为碎碎念,心急者请步移Step6.)

【安装Mysql for Python,这一步的安装极为痛苦,由于作者并没有发布安装包,在配置的时候错误不断,先是找不到Mysql的注册键值(因为其site.cfg文件中SOFTWARE\MySQL AB\MySQL Server 5.0的值和安装的mysql版本不一致,把5.0修改成安装的版本号5.5问题解决),然后又提示“Unable to find vcvarsall.bat”(因为未安装Visual Studio,而且,更脑残的是必须是VS2008!),最后,坑爹的装了个VS 2010 C++ Express版,改注册表伪装VS2008,竟然又提示说找不到什么头文件,顿时死的心都有了……】

 

Step 6. 现在,开始创建Django工程吧

在要创建的目录下执行

python django-admin.py startproject whulecture

则会在要创建目录下建立whulecture工程

 

Step 7. 启动自带web服务器(仅供开发,生产使用建议选Apache)

在工程目录下运行

 python manage.py runserver

就会启动web服务器

(默认是http://127.0.0.1:8000/,可以用python manage.py runserver 8080 修改)

打开浏览器转到http://127.0.0.1:8000/,不出意外会看到欢迎界面,配置成功!Have fun!

20 Comments (+add yours?)

  1. 小钟同学
    11月 09, 2011 @ 23:01:51

    好漂亮的网站啊,哇哈哈,我以后也要做一个这样的,哇哈哈

    回复

  2. Kiera
    8月 31, 2014 @ 01:10:30

    I read a lot of interesting articles here. Probably you spend a lot of time writing, i know how to save
    you a lot of time, there is an online tool that creates readable, google friendly posts in minutes, just search in google – laranitas free content source

    回复

  3. Content Generator
    11月 20, 2022 @ 08:37:26

    Artificial intelligence creates content for the site, no worse than a copywriter, you can also use it to write articles. 100% uniqueness :). Click Here: https://stanford.io/3FXszd0

    回复

  4. 匿名
    12月 26, 2022 @ 00:28:36

    промокоды мелбет при регистрации. Click Here: http://lynks.ru/geshi/php/?melbet_promokod_pri_registracii_2020.html

    回复

  5. Code Promo 1xBet
    1月 10, 2023 @ 00:13:29

    回复

  6. 1xbet promo code
    1月 28, 2023 @ 15:41:01

    回复

  7. промокод на 1хбет
    2月 08, 2023 @ 23:18:14

    Artificial intelligence creates content for the site, no worse than a copywriter, you can also use it to write articles. 100% uniqueness,5-day free trial of Pro Plan :). Click Here: https://whitestudios.ru/kassa/incs/1xbet_besplatno_stavka-2021.html

    回复

  8. 1хбет промокод
    2月 09, 2023 @ 12:09:37

    Artificial intelligence creates content for the site, no worse than a copywriter, you can also use it to write articles. 100% uniqueness,5-day free trial of Pro Plan :). Click Here: https://dakelin.ru/news/promokod_143.html

    回复

  9. промокод 1 икс бет
    2月 09, 2023 @ 20:12:58

    Artificial intelligence creates content for the site, no worse than a copywriter, you can also use it to write articles. 100% uniqueness,5-day free trial of Pro Plan :). Click Here: https://ceramicinspirations.co.uk/articles/promokod_191.html

    回复

  10. melbet promo code
    2月 11, 2023 @ 22:18:09

    回复

  11. promo code for 1xbet
    2月 12, 2023 @ 13:24:39

    回复

  12. promo code 1xbet
    2月 12, 2023 @ 13:25:05

    promo code for 1xbet bangladesh Click Here: https://www.lafp.org/includes/pages/1xbet-promo-code-1xbet-bonus.html

    回复

  13. бонус код мелбет
    2月 12, 2023 @ 19:44:22

    回复

  14. Phone Number For Reservations
    3月 01, 2023 @ 22:58:33

    Phone Number For Reservations: http://rentry.co/t46vcq

    回复

  15. Phone Number For Reservations
    3月 02, 2023 @ 02:29:52

    Phone Number For Reservations: http://rentry.co/ha6nu

    回复

  16. Phone Number For Reservations
    3月 03, 2023 @ 09:44:54

    Phone Number For Reservations: http://rentry.co/g93fzm

    回复

  17. ixbet promo code
    3月 07, 2023 @ 04:10:15

    回复

  18. 1 x bet promo code bangladesh
    3月 07, 2023 @ 18:03:42

    回复

  19. секс чат вирт секс
    3月 08, 2023 @ 06:52:31

    бесплатно секс чат. Click Here: https://rt.beautygocams.com/

    回复

  20. промокод при регистрации мелбет
    3月 08, 2023 @ 23:23:49

    промокод на мелбет на бесплатную ставку. Click Here: https://mebel-3d.ru/libraries/news/?melbet_2020_promokod_dlya_registracii_besplatno.html

    回复

Leave a Reply