Django integrated to mod_python
1.download django-0.9.6
2.uncompress then run: python setup.py install
3.Add the python/Scripts to env path
4.Add the .py to the PATHEXE
So far,you can set up a project.
Steps:
1.create a directory in c:/mysite
2.django-admin.py startproject mysite
Setup an application (polls)
1.c:\mysite>python mysite\manage.py startapp polls
2.modify the polls\models.py
from django.db import models
class Poll(models.Model):
question = models.CharField(maxlength=200)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(maxlength=200)
votes = models.IntegerField()
3.edit the setting.py
.configure the database connection
.modify below:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'mysite.polls'
)
4.execute the command then create the schema in mysql
c:\mysite>python mysite/manage.py sql polls
success,you can see below:
BEGIN;
CREATE TABLE "polls_poll" (
"id" serial NOT NULL PRIMARY KEY,
"question" varchar(200) NOT NULL,
"pub_date" timestamp with time zone NOT NULL
);
CREATE TABLE "polls_choice" (
"id" serial NOT NULL PRIMARY KEY,
"poll_id" integer NOT NULL REFERENCES "polls_poll" ("id"),
"choice" varchar(200) NOT NULL,
"votes" integer NOT NULL
);
COMMIT;
5.Create the table and session
c:\mysite>python mysite/manage.py syncdb
6.python mysite/manage.py shell
>>>from mysite.polls.models import Poll, Choice
>>>Poll.objects.all()
>>>Poll.objects.filter(id=1)
分享到:
相关推荐
Django 2 Web Development Cookbook 100 practical recipes on building scalable Python web apps with Django 2
Django 2 Web Development Cookbook 100 practical recipes on building scalable Python web apps with Django 2, 3rd Edition
Web Development with Django Cookbook 英文版 Web Development with Django Cookbook 英文版 Web Development with Django Cookbook 英文版
### Python Web Development With Django #### 一、书籍概述与定位 本书《Python Web Development With Django》是一本关于使用Python和Django框架进行Web开发的专业书籍。与其他市场上已有的Django书籍相比,本书...
The Definitive Guide to Django - Web Development Done Right(2nd) 英文无水印pdf 第2版 pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 ...
《Web Development with Django Cookbook, Second Edition》是一本深入探讨使用Django框架进行Web开发的实战指南。这本书的第二版更新了最新的Django版本知识,旨在帮助开发者高效地解决在构建Web应用过程中遇到的...
Learning Website Development with Django.epub
《Python Web Development with Django》是专门讲解如何使用Python语言和Django框架进行Web开发的一本书。这本书属于“Developer’s Library”系列,该系列为程序员提供高质量的编程参考书籍和教程。该系列书籍由...
**Python Web开发与Django框架详解** 在现代Web开发领域,Python以其简洁、优雅的语法和强大的库支持,成为了一种流行的编程语言。而Django,作为Python的顶级Web框架,以其“ batteries included ”(内置功能全面...
本书《Django for beginners learn web development with Django 2.0》面向对Web开发感兴趣的初学者,旨在通过项目驱动的方式教授使用Django 2.0框架开发Web应用程序的技能,强调使用Python 3.x版本。虽然本书是英文...
《Web Development with Django Cookbook, 2nd Edition》是一本专注于使用Django 1.8框架开发可扩展网站的实用指南,汇集了90多个实际配方。本书由Aidas Bendoraitis撰写,是Django开发人员的宝贵资源,提供了丰富的...
Django is a web framework that was designed to strike a balance between rapid web development and high performance. It has the capacity to handle applications with high levels of user traffic and ...
A practical guide to Django template development with custom tags, filters, multiple templates, caching, and more Scott Newman
Web Development with Django Cookbook - Second Edition will guide you through all the web development process with Django 1.8 framework. You will get started with the virtual environment and ...
《Web Development with Django Cookbook, Second Edition》(第二版)是关于Django Web开发的实践指导书籍。Django是一个高级的Python Web框架,它鼓励快速开发和干净、实用的设计。这本书由Aidas Bendoraitis编写...
《Django Web Development with Python》是一本专注于使用Python语言进行Django框架开发的书籍,它提供了详尽的指导,帮助开发者构建高效、安全且可扩展的Web应用。Django是Python社区中最受欢迎的Web框架之一,以其...
Test Driven Development with Django 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请...