码迷,mamicode.com
首页 > 数据库 > 详细

django python3 实例 mysql数据库

时间:2014-10-13 01:37:28      阅读:329      评论:0      收藏:0      [点我收藏+]

标签:style   http   color   io   os   ar   数据   sp   on   

views.py中代码:

def show_all_user(req):
num=1
if ‘pagenum‘ in req.POST:
num=req.POST[‘pagenum‘]
tlist=User.objects.all()
p=Paginator(tlist,30)
page=p.page(num)
return render_to_response(‘show_all_user.html‘,{‘all_user‘:page.object_list,‘pagenum‘:num,‘total‘:range(1,p.num_pages+1)})

 

settings.py


import os


BASE_DIR = os.path.dirname(os.path.dirname(__file__))
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), ‘../templates‘).replace(‘\\‘,‘/‘),
os.path.join(os.path.dirname(__file__), ‘../activitypush/templates/‘).replace(‘\\‘,‘/‘),
# os.path.join(os.path.dirname(__file__), ‘../activitypush/js/‘).replace(‘\\‘,‘/‘),
os.path.join(os.path.dirname(__file__), ‘../mysite/templates/‘).replace(‘\\‘,‘/‘),
os.path.join(os.path.dirname(__file__), ‘../upload/templates/‘).replace(‘\\‘,‘/‘),

os.path.dirname(os.path.dirname(__file__)),


os.path.join(os.path.dirname(__file__), ‘../activitypush/static/js/‘).replace(‘\\‘,‘/‘),
os.path.join(os.path.dirname(__file__), ‘../mysite/templates/‘).replace(‘\\‘,‘/‘),
)

STATIC_URL = ‘/static/‘


STATICFILES_DIRS = (
os.path.join(os.path.dirname(__file__), ‘../static/‘).replace(‘\\‘,‘/‘),
os.path.join(os.path.dirname(__file__), ‘../activitypush/static/‘).replace(‘\\‘,‘/‘),
os.path.join(os.path.dirname(__file__), ‘../mysite/static/‘).replace(‘\\‘,‘/‘),
os.path.join(os.path.dirname(__file__), ‘../clientloading/static/‘).replace(‘\\‘,‘/‘),
os.path.join(os.path.dirname(__file__), ‘../upload/static/‘).replace(‘\\‘,‘/‘),
os.path.join(os.path.dirname(__file__), ‘../myauth/static/‘).replace(‘\\‘,‘/‘),
)

STATIC_PATH = os.path.join(os.path.dirname(__file__), ‘../templates‘).replace(‘\\‘,‘/‘)

SECRET_KEY = ‘a=is^$ivb)$s5$_fq+(6leza+&2z$=(s-2-*v4i$@b#z66j*yu‘

# SECURITY WARNING: don‘t run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []

SITE_ID = 1

# Application definition

INSTALLED_APPS = (
‘django.contrib.admin‘,
‘django.contrib.auth‘,
‘django.contrib.contenttypes‘,
‘django.contrib.sessions‘,
‘django.contrib.messages‘,
‘django.contrib.staticfiles‘,

‘django.contrib.sites‘,
‘django.contrib.admindocs‘
)

MIDDLEWARE_CLASSES = (
‘django.contrib.sessions.middleware.SessionMiddleware‘,
‘django.middleware.common.CommonMiddleware‘,
‘django.middleware.csrf.CsrfViewMiddleware‘,
‘django.contrib.auth.middleware.AuthenticationMiddleware‘,
‘django.contrib.messages.middleware.MessageMiddleware‘,
‘django.middleware.clickjacking.XFrameOptionsMiddleware‘,

‘django.core.files.uploadhandler.MemoryFileUploadHandler‘,
‘django.core.files.uploadhandler.TemporaryFileUploadHandler‘,
)

ROOT_URLCONF = ‘mysite.urls‘

WSGI_APPLICATION = ‘mysite.wsgi.application‘

 

DATABASES = {
‘default‘: {
‘ENGINE‘:‘django.db.backends.mysql‘,
‘NAME‘: ‘django‘,
‘USER‘: ‘root‘,
‘PASSWORD‘: ‘root‘,
‘HOST‘: ‘localhost‘,
‘PORT‘: ‘3306‘,
}
}

 

完整代码下载地址为:http://download.csdn.net/detail/dxldehuali/8030623

小编的店铺地址,欢迎光顾:http://yunduosuper.taobao.com/

django python3 实例 mysql数据库

标签:style   http   color   io   os   ar   数据   sp   on   

原文地址:http://www.cnblogs.com/yanguilaixi/p/4021300.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!