Djnogo Web开发学习笔记(2)
安 装
截止目前,https://www.djangoproject.com/download/提供的最新的Django的下载版本为1.6.4.
Install Django
You’ve got three easy options to install Django:
- Install a version of Django provided by your operating system distribution. This is the quickest option for those who have operating systems that distribute Django.
- Install an official release. This is the best approach for users who want a stable version number and aren’t concerned about running a slightly older version of Django.
- Install the latest development version. This is best for users who want the latest-and-greatest features and aren’t afraid of running brand-new code.
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下自带的服务器,发现如下界面:
可以看到如下界面,表示运行成功:
如果发现端口被占用(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)的更多相关文章
- 【前端】移动端Web开发学习笔记【2】 & flex布局
上一篇:移动端Web开发学习笔记[1] meta标签 width设置的是layout viewport 的宽度 initial-scale=1.0 自带 width=device-width 最佳实践 ...
- 【前端】移动端Web开发学习笔记【1】
下一篇:移动端Web开发学习笔记[2] Part 1: 两篇重要的博客 有两篇翻译过来的博客值得一看: 两个viewport的故事(第一部分) 两个viewport的故事(第二部分) 这两篇博客探讨了 ...
- ASP.NET Core Web开发学习笔记-1介绍篇
ASP.NET Core Web开发学习笔记-1介绍篇 给大家说声报歉,从2012年个人情感破裂的那一天,本人的51CTO,CnBlogs,Csdn,QQ,Weboo就再也没有更新过.踏实的生活(曾辞 ...
- PHP和MySQL Web开发学习笔记介绍
前言 从2016年2月1日开始,之后的几个月左右的时间里,我会写一个系列的PHP和MySQL Web开发的学习笔记.我之前一直从事Java语言的开发工作,最近这段时间非常想学习一门语言,就选择了PHP ...
- 【web开发学习笔记】Structs2 Result学习笔记(三)带參数的结果集
Result学习笔记(三)带參数的结果集 第一部分:代码 //前端 <head> <meta http-equiv="Content-Type" content= ...
- 【web开发学习笔记】Structs2 Result学习笔记(二)动态结果集
Result学习笔记(二) - 动态结果集 动态结果 一定不要忘了为动态结果的保存值设置set get方法 第一部分:代码 //前端 <% String context = reques ...
- 【web开发学习笔记】Structs2 Action学习笔记(两)
action学习笔记2-大约action method讨论 Action运行的时候并不一定要运行execute方法,能够在配置文件里配置Action的时候用method=来指定运行哪个方法 也能够在u ...
- Django Web开发学习笔记(1)
一.Python的标准类型 (1)bool型 >>> bool("") False >>> bool(None) False >>& ...
- 【web开发学习笔记】Structs2 Result学习笔记(一)简介
Structs2 Result学习笔记(一)简介 问题一 <struts> <constant name="struts.devMode" value=" ...
随机推荐
- json文本和json对象之间的转换
在数据传输过程中,json是以文本,即字符串的形式传递的,而JS操作的是JSON对象,所以,JSON对象和JSON字符串之间的相互转换是关键.例如: //JSON字符串: var str1 = '{ ...
- [转] Web MVC简介
http://blog.csdn.net/zk_software/article/details/8141843
- [转] Java接口_interface_implements
相对抽象类来讲,接口就是比抽象类还要抽象的抽象类,丝毫不带半点实现的内容.接口可以更加规范的对子类进行约束.接口全面地专业地实现了:规范和具体实现的分离.接口就是规范,定义的是一组规则,提现了现实世界 ...
- python全栈开发day31-操作系统介绍,异步、同步、阻塞、非阻塞,进程
一.网络编程内容回顾 1.arp协议 #交换机 #广播.单播 2.ip协议 3.tcp和udp协议 tcp:可靠的,面向连接的,字节流传输,长连接 三次握手:一方发送请求,另一方确认请求同时发送请求, ...
- BZOJ1567 [JSOI2008]Blue Mary的战役地图 二分答案 哈希
欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1567 题意概括 给出两个n*n的数字矩阵,问最大公共正方形边长. 题解 先二分答案一个m,对于每一 ...
- JdbcType类型和Java类型的对应关系
在Oracle中有些字段不是必填时在用户使用的时候会出现数据null的情况.这个时候在Oracle中是无法进行插入的. JDBC Type Java Type CHAR String VARCHAR ...
- 032 HDFS中高可用性HA的讲解
HDFS Using QJM HA使用的是分布式的日志管理方式 一:概述 1.背景 如果namenode出现问题,整个HDFS集群将不能使用. 是不是可以有两个namenode呢 一个为对外服务-&g ...
- Linux —— 目录(文件夹)及文件相关处理指令
可参考这篇文章:https://mp.weixin.qq.com/s?__biz=MzU4MTU3OTI0Mg==&mid=2247484269&idx=1&sn=38869a ...
- iOS11开发教程(二十三)iOS11应用视图实现按钮的响应(3)
iOS11开发教程(二十三)iOS11应用视图实现按钮的响应(3) 2.使用代码添加按钮实现的响应 使用代码添加的按钮,实现响应需要使用到addTarget(_:action:for:)方法,其语法形 ...
- 你了解ECMAScript吗?
一.基本概念ECMA,European Computer Manufacturers Association,欧洲计算机制造协会. TC39,Technical Committee 39,ECMA的第 ...