Django Python3 instance MySQL database

Source: Internet
Author: User
Tags auth sessions

Code in 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 ':p age.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) $s 5$_fq+ (6leza+&2z$= (s-2-*[email protected] #z66j *yu '

# SECURITY Warning:don ' t run with debug turned on 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 ',
}
}

The complete code is: http://download.csdn.net/detail/dxldehuali/8030623

Shop address of Small series, Welcome to visit: http://yunduosuper.taobao.com/

Django Python3 instance MySQL database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.