django---first application
来源:互联网 发布:linux项目开发实例 编辑:程序博客网 时间:2024/06/15 06:48
1.django源码安装
进入源码目录,执行python setup.py install
2.创建django工程
进入工程父目录,执行django-admin startproject test1
3.创建django应用
进入工程目录test1,执行django-admin startapp app1
4.配置settings.py
INSTALLED_APP add----->app1
5.配置urls.py
url(r'app1/idnex/$', 'app1.views.index')
6.配置views.py
from django.shortcuts import render_to_response
def index(req):
return render_to_response('index.html')
或
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader, Context
def index(req):
t = loader.get_template('index.html')
c = Context({})
return HttpResponse(t.render(c))
7.创建html文件
先在应用目录app1下创建templates目录,进入templates目录,创建index.html文件
<html>
<head></head>
<body>
<h1>Hello test1!</h1>
</body>
</html>
8.启动服务
进入工程目录,python manager.py runserver
默认url: 127.0.0.1:8000
- django---first application
- Your First Struts Application
- Your First Struts Application
- My First Symbian Application
- My First Hibernate Application
- My First DirectShow Application
- My first WPF application
- The First MFC Application
- MY first android application
- my first php application
- The first Android application
- Your first PySide application
- my first Grails application
- Your first Kaa application
- The First Ryu Application
- First Django-powered page
- Django 学习first
- Django(三)--First Project
- Linux 常用命令
- 马震宇-360问答系统(基于HDPHP)
- 记录一次很遗憾的面试经历
- InnoDB存储引擎——后台线程
- 数的划分 不同思路与解法
- django---first application
- 官方Spark Programming Guide学习心得(V2.1.0)
- 关于数据库优化
- LQB 1K
- 10的100次方是哪个公司
- Docker存储驱动之OverlayFS简介
- 事件驱动VS消息驱动
- 伪代码--懂点就行,不要当真
- 计算机三级考试准备笔记