Python Django Build Database Web site

Source: Internet
Author: User

Recently want to do a database site, I am very familiar with Python, but also understand that Django is very useful, so talk about it.

First, on the fast cloud bought a VPS, a dollar trial for one months, Ubuntu system.

1. Installation
apt-get updateaptinstall python-pip python-dev build-install Django

There are many methods of installation and can be freely chosen.

2. Create PRJ and Apps
#创建项目django-admin.py startproject test01
./├──manage.py    #管理器 └──test01    #项目目录    ├──__init__.py    #包文件    ├──settings.py    #项目配置文件    ├──urls.py    #URL管理器    └──wsgi.py    #服务器连接工具
Modify settings.py file, add blog to Installed_apps

Modify the urls.py file, url (r ' ^blog/index/$ ', ' Blog.views.index ') for website testing

Note: Be sure to build the app in the root directory of the project, otherwise it will be problematic *

 from Import  = [    url (r'^admin/', admin.site.urls),    URL (r')  ^blog/index/$', index),]
#创建应用django-admin.py Startapp Blog
./├──blog│├──admin.py│├──apps.py│├──__init__.py│├──migrations││└──__init__.py│├──models.py    # Database Explorer │├──tests.py│└──views.py    # view operator ├──__init__.py├──settings.py├──urls.py└──wsgi.py
Modify the views.py file in the blog, add the function index,
 from Import HttpResponse def Index (req):     return HttpResponse ('')
Then, test, you can use the W3m browser under the shell interface
Python manage.py runserver
w3m Http://127.0.0.1:8000/blog/index

OK, Test success!!!

Python Django Build Database Web site

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.