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