Django笔记1_环境搭建

来源:互联网 发布:java selector 编辑:程序博客网 时间:2024/05/09 09:21

一、软件安装

</pre><p></p><p><span style="white-space:pre"></span>Python3.4.1+Django1.7.1+Mysql5.6</p><p><span style="white-space:pre"></span>1,安装Python3.4.1 ,不多说</p><p><span style="white-space:pre"></span>2.,dos窗口切换到python的安装目录下的Python34\Scripts 利用pip 安装Django  </p><p><span style="white-space:pre"></span></p><pre name="code" class="plain"><span style="white-space:pre"></span>pip install django==1.7.1

2.安装mysql 不详细叙述

3安装MySQLdb 我是很久之前安装好的,具体怎么装的忘了,有几种思路,1.利用pip 或者easy_install.或者下载源码包,或者寻找msi文件但一定要对应好版本。


二环境配置

在任一目录下运行 python django-main.py startproject   projectName    其中projectName是你的项目名称 或生产projectName的一个文件夹包含一个manage.py 文件和一个projectName同名的文件夹,里面包含__init__.py  __settings.py__  __urls.py__  __wsgi.py__ 四个文件。

  • manage.py: A command-line utility that lets you interact with this Django project in various ways. You can read all the details about manage.py in django-admin.py and manage.py.(很多明明)
  • The inner mysite/ directory is the actual Python package for your project. Its name is the Python package name you’ll need to use to import anything inside it (e.g. mysite.urls).
  • mysite/__init__.py: An empty file that tells Python that this directory should be considered a Python package. (Read more about packages in the official Python docs if you’re a Python beginner.)
  • mysite/settings.py: Settings/configuration for this Django project. Django settings will tell you all about how settings work. (设置文件,包括数据库的设置都在里面)
  • mysite/urls.py: The URL declarations for this Django project; a “table of contents” of your Django-powered site. You can read more about URLs in URL dispatcher.(指定url)
  • mysite/wsgi.py: An entry-point for WSGI-compatible web servers to serve your project. See How to deploy with WSGI for more details.(有何用处体会不深)

__settings.py__ MySQL的配置



DATABASES = {
    'default': {
'ENGINE':'django.db.backends.mysql',
'NAME':'pythondb',
'USER':'root',
'PASSWORD':'root',
'HOST':'127.0.0.1',
'PORT':'3306'
    }
}

各个文件的说明  想系参考django1.7 的文档 如果你不是1.7 请更换对应版本,1.7和之前版本有区别的。

http://django-cn.readthedocs.org/zh_CN/1.7/intro/tutorial01.html

0 0
原创粉丝点击