订单系统(django + python +dwz)

一.运行zt框架
1.安装JPype-0.5.4.win32-py2.5.exe      simplejson-2.1.1.win32-py2.5.exe

2.cmd下切换目录到zt根目录 键入 python manage.py runserver  
    显示0 error 。

3.浏览器下输入http://127.0.0.1:8000/


二.订单管理搭建
1.在zt/urls.py中添加
url(r'^b120910ordermanagement/', include('zt.a120910ordermanagement.urls')),

2.setting.py 的DATABASES = {}中添加数据库连接代码
'order': {
               'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
               'OPTIONS': {'use_unicode':'true',#'characterEncoding':'utf8',
                               #'zeroDateTimeBehavior':'round',
                               } ,
               'NAME': r'order',                                           # Or path to database file if using sqlite3.
               'USER': 'fresh',                                           # Not used with sqlite3.
               'PASSWORD': '0123456789',                                   # Not used with sqlite3.
               'HOST': '192.168.0.97',                                           # Set to empty string for localhost. Not used with sqlite3.
               'PORT': '3306',
       }

3.在zt/a120910ordermanagement目录下创建 __init__.py   urls.py   view.py   model.py文件
#---view.py:-------#
# -*- coding: utf-8 -*-
from zt.a120910ordermanagement.models import *
from django.template.response import TemplateResponse

#全局变量
content_type = "text/html;charset=utf-8"

def index(request):
       return TemplateResponse(request, "a120910ordermanagement/index.html", None, content_type)

#---urls.py:-------#
'''
Created on 2012-9-10

@author: yang.wang
'''
from django.conf.urls.defaults import *
from zt.a120910ordermanagement.views import *

urlpatterns = patterns('',
       url(r'^$', index),
)

#---model.py:-------#
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#         * Rearrange models' order
#         * Make sure each model has one field with primary_key=True
# Feel free to rename the models, but don't rename db_table values or field names.
#
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'
# into your database.

from django.db import models

class Team(models.Model):
       id = models.IntegerField(primary_key=True, db_column='ID') # Field name made lowercase.
       name = models.CharField(max_length=96, unique=True, db_column='NAME') # Field name made lowercase.
       created_date = models.DateTimeField(db_column='CREATED_DATE') # Field name made lowercase.
       status = models.IntegerField(null=True, db_column='STATUS', blank=True) # Field name made lowercase.
       class Meta:
               db_table = u'TEAM'

       def __unicode__(self):
               return self.name

class TeamHistory(models.Model):
       order_number = models.IntegerField(primary_key=True, db_column='ORDER_NUMBER') # Field name made lowercase.
       team = models.ForeignKey(Team, db_column='TEAM_ID') # Field name made lowercase.
       consumption = models.FloatField(null=True, db_column='CONSUMPTION', blank=True) # Field name made lowercase.
       comment = models.CharField(max_length=300, db_column='COMMENT', blank=True) # Field name made lowercase.
       created_date = models.DateTimeField(db_column='CREATED_DATE') # Field name made lowercase.
       status = models.IntegerField(null=True, db_column='STATUS', blank=True) # Field name made lowercase.
       class Meta:
               db_table = u'TEAM_HISTORY'

       def __unicode__(self):
               return self.name

class User(models.Model):
       id = models.IntegerField(primary_key=True, db_column='ID') # Field name made lowercase.
       name = models.CharField(max_length=96, unique=True, db_column='NAME') # Field name made lowercase.
       password = models.CharField(max_length=96, db_column='PASSWORD') # Field name made lowercase.
       authority = models.IntegerField(null=True, db_column='AUTHORITY', blank=True) # Field name made lowercase.
       comment = models.CharField(max_length=300, db_column='COMMENT', blank=True) # Field name made lowercase.
       email = models.CharField(max_length=96, db_column='EMAIL', blank=True) # Field name made lowercase.
       created_date = models.DateTimeField(db_column='CREATED_DATE') # Field name made lowercase.
       status = models.IntegerField(null=True, db_column='STATUS', blank=True) # Field name made lowercase.
       class Meta:
               db_table = u'USER'

       def __unicode__(self):
               return self.name

class UserChargeHistory(models.Model):
       id = models.IntegerField(primary_key=True, db_column='ID') # Field name made lowercase.
       user = models.ForeignKey(User, db_column='USER_ID') # Field name made lowercase.
       team = models.ForeignKey(Team, db_column='TEAM_ID') # Field name made lowercase.
       charge = models.FloatField(null=True, db_column='CHARGE', blank=True) # Field name made lowercase.
       created_date = models.DateTimeField(db_column='CREATED_DATE') # Field name made lowercase.
       status = models.IntegerField(null=True, db_column='STATUS', blank=True) # Field name made lowercase.
       class Meta:
               db_table = u'USER_CHARGE_HISTORY'

       def __unicode__(self):
               return self.name

class UserHistory(models.Model):
       team_history_order_number = models.ForeignKey(TeamHistory, primary_key=True, db_column='TEAM_HISTORY_ORDER_NUMBER') # Field name made lowercase.
       user = models.ForeignKey(User, db_column='USER_ID') # Field name made lowercase.
       consumption = models.FloatField(null=True, db_column='CONSUMPTION', blank=True) # Field name made lowercase.
       created_date = models.DateTimeField(db_column='CREATED_DATE') # Field name made lowercase.
       status = models.IntegerField(null=True, db_column='STATUS', blank=True) # Field name made lowercase.
       class Meta:
               db_table = u'USER_HISTORY'

       def __unicode__(self):
               return self.name

class UserTeam(models.Model):
       id = models.IntegerField(primary_key=True, db_column='ID') # Field name made lowercase.
       user = models.ForeignKey(User, db_column='USER_ID') # Field name made lowercase.
       team = models.ForeignKey(Team, db_column='TEAM_ID') # Field name made lowercase.
       balance = models.FloatField(null=True, db_column='BALANCE', blank=True) # Field name made lowercase.
       flag = models.IntegerField(null=True, db_column='FLAG', blank=True) # Field name made lowercase.
       created_date = models.DateTimeField(db_column='CREATED_DATE') # Field name made lowercase.
       status = models.IntegerField(null=True, db_column='STATUS', blank=True) # Field name made lowercase.
       class Meta:
               db_table = u'USER_TEAM'

       def __unicode__(self):
               return self.name

4.在zt/templates/b120910ordermanagement/下创建 index.html

  
  
  
     wangyang hello world
  

5.浏览器里访问网址 127.0.0.1:8000/b120910ordermanagement可得到如下页面

就此框架成功。


你可能感兴趣的:(python)