安   装

截止目前,https://www.djangoproject.com/download/提供的最新的Django的下载版本为1.6.4.

Install Django

You’ve got three easy options to install Django:

windows下安装Djnogo的方式在说明文档https://docs.djangoproject.com/en/1.6/howto/windows/

Test Install

After the installation has completed, you can verify your Django installation by executing django-admin.py --version in the command prompt.

因为我的是安装的1.6.4 因此,可以看到如图所示:

安装完成后,Django会被安置在../Lib/site-packages下面

Set  Environments path

将C:/Python27/Lib/site-packages/django添加到环境变量下面,就可以利用django-admin.py创建工程了!

该文件位于目录 C:\Python27\Lib\site-packages\django\bin下面

Writing your first Django app

Creating a project

打开到django-admin.py的目录环境下,执行 django-admin.py startproject myproject ,可以发现生成一个新的文件夹“myproject",并且其中会有一些新生成的文件和目录。如果希望在别的工程目录下面创建自己的工程,可以在工程名称后面添加执行的路径,例如:django-admin.py startproject myproject C:\MyProject

__init__.py:表明该目录为一个python包

setting.py:项目设置文件

  urls.py:URL映射管理

manage.py:对项目进行操作的命令

wsgi.py:Python Web Server Gateway Interface,是Python应用程序或框架和Web服务器之间的一种接口。

参考文件中的英文文档说明:

  • The outer mysite/ root directory is just a container for your project. Its name doesn’t matter to Django; you can rename it to anything you like.
  • 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.
  • mysite/wsgi.py: An entry-point for WSGI-compatible web servers to serve your project. See How to deploy with WSGI for more details.

其中的mysite就是我们创建的myproject

The development server

Let’s verify this worked. Change into the outer mysite directory, if you haven’t already, and run the command python manage.py runserver. You’ll see the following output on the command line:

进入我们新建的工程目录,发现名为manage.py的文件,然后运行 python manage.py runserver. 该服务器是在Django下自带的服务器,发现如下界面:

输入网址:http://127.0.0.1:8000/

可以看到如下界面,表示运行成功:

如果发现端口被占用(netstat-ano)我们也可以修改端口指令

Changing the port

By default, the runserver command starts the development server on the internal IP at port 8000.

If you want to change the server’s port, pass it as a command-line argument. For instance, this command starts the server on port 8080:

$ python manage.py runserver 8080

If you want to change the server’s IP, pass it along with the port. So to listen on all public IPs (useful if you want to show off your work on other computers), use:

$ python manage.py runserver 0.0.0.0:8000

Full docs for the development server can be found in the runserver reference.

这样我们基本完成了环境搭建,下一节我们将介绍怎样创建前台!

参考:

[1]https://docs.djangoproject.com

[2]http://www.cnblogs.com/zhoujie/archive/2013/05/11/django1.html

Djnogo Web开发学习笔记(2)的更多相关文章

  1. 【前端】移动端Web开发学习笔记【2】 & flex布局

    上一篇:移动端Web开发学习笔记[1] meta标签 width设置的是layout viewport 的宽度 initial-scale=1.0 自带 width=device-width 最佳实践 ...

  2. 【前端】移动端Web开发学习笔记【1】

    下一篇:移动端Web开发学习笔记[2] Part 1: 两篇重要的博客 有两篇翻译过来的博客值得一看: 两个viewport的故事(第一部分) 两个viewport的故事(第二部分) 这两篇博客探讨了 ...

  3. ASP.NET Core Web开发学习笔记-1介绍篇

    ASP.NET Core Web开发学习笔记-1介绍篇 给大家说声报歉,从2012年个人情感破裂的那一天,本人的51CTO,CnBlogs,Csdn,QQ,Weboo就再也没有更新过.踏实的生活(曾辞 ...

  4. PHP和MySQL Web开发学习笔记介绍

    前言 从2016年2月1日开始,之后的几个月左右的时间里,我会写一个系列的PHP和MySQL Web开发的学习笔记.我之前一直从事Java语言的开发工作,最近这段时间非常想学习一门语言,就选择了PHP ...

  5. 【web开发学习笔记】Structs2 Result学习笔记(三)带參数的结果集

    Result学习笔记(三)带參数的结果集 第一部分:代码 //前端 <head> <meta http-equiv="Content-Type" content= ...

  6. 【web开发学习笔记】Structs2 Result学习笔记(二)动态结果集

    Result学习笔记(二) - 动态结果集     动态结果 一定不要忘了为动态结果的保存值设置set get方法 第一部分:代码 //前端 <% String context = reques ...

  7. 【web开发学习笔记】Structs2 Action学习笔记(两)

    action学习笔记2-大约action method讨论 Action运行的时候并不一定要运行execute方法,能够在配置文件里配置Action的时候用method=来指定运行哪个方法 也能够在u ...

  8. Django Web开发学习笔记(1)

    一.Python的标准类型 (1)bool型 >>> bool("") False >>> bool(None) False >>& ...

  9. 【web开发学习笔记】Structs2 Result学习笔记(一)简介

    Structs2 Result学习笔记(一)简介 问题一 <struts> <constant name="struts.devMode" value=" ...

随机推荐

  1. Hibernate之关联关系映射(一对一主键映射和一对一外键映射)

    1:Hibernate的关联关系映射的一对一外键映射: 1.1:第一首先引包,省略 1.2:第二创建实体类: 这里使用用户信息和身份证信息的关系,用户的主键编号既可以做身份证信息的主键又可以做身份证信 ...

  2. canvas简单下雨特效

    前面做了两个简单的效果,这次就来个下雨的效果 思路简单的说一下 随机在屏幕中的位置画雨滴,moveTo(x,y) 雨滴的长度就是lineTo(x,y+len) 每次重新绘制页面,就能达到下雨的效果了 ...

  3. python学习之基本数据类型

    python的基本数据类型有数字.字符串.列表.字典.元祖.布尔值 一.数字 1.1.字符转换为数字 实例: a=" b=int(a) print(b+) 运行结果: 可以用type查看数据 ...

  4. jquery中方法扩展 ($.fn & $.extend) 学习笔记

    A.$.fn 1.$.fn.method() 函数为jQuery对象扩展一个属性和方法(主要用于扩展方法) :method 为自定义方法名 ($.fn 等效 $.prototype) $.fn.bor ...

  5. spring继承Rabbitmq client-----------------------待研究

    一:概述 1.官网 https://spring.io/ 2.进入project 3.找到spring AMQP 二:程序 1.结构 2.pom <?xml version="1.0& ...

  6. Python爬虫之selenium的使用(八)

    Python爬虫之selenium的使用 一.简介 二.安装 三.使用 一.简介 Selenium 是自动化测试工具.它支持各种浏览器,包括 Chrome,Safari,Firefox 等主流界面式浏 ...

  7. 029.Docker Compose部署Zabbix实战

    一 前期规划 1.1 Zabbix架构图 1.2 其他规划 组件 类型 版本 备注 Zabbix Web zabbix-web-apache-mysql镜像 wordpress:latest 也可采用 ...

  8. c# 深入探索之CLR

    概念: CLR : 公共语言运行时(Common Language Runtime) 是一个可由多种编程语言使用的"运行时",它负责资源管理(内存分配和垃圾收集等),并保证应用和底 ...

  9. IdentityServer4-用EF配置Client(一)

    一.背景 IdentityServer4的介绍将不再叙述,百度下可以找到,且官网的快速入门例子也有翻译的版本.这里主要从Client应用场景方面介绍对IdentityServer4的应用. 首先简要介 ...

  10. 是否可从一个static方法内发出对非static方法的调用?

    不可以.因为非static方法是要与对象关联在一起的,必须创建一个对象后,才可以在该对象上进行方法调用,而static方法调用时不需要创建对象,可以直接调用.也就是说,当一个static方法被调用时, ...