首页 > 代码库 > 安装django
安装django
yum install sqlite-devel
安装python2.7
安装setuptools readline
查看 安装setuptools readline 过程
http://www.cnblogs.com/augustyang/p/6809013.html
之后安装django
wget https://www.djangoproject.com/download/1.8.18/tarball/ --no-check-certificate
tar -xf Django-1.8.18.tar.gz && cd Django-1.8.18
python setup.py install
>>> import django
>>> django.VERSION
(1, 8, 18, ‘final‘, 0)
>>>
说明安装成功
--------------------------------------------------------------------------------------------------------------------
1.新建一个项目
django-admin.py startproject project_name
2.新建一个app
cd project_name
python manage.py startapp app_yang
一般一个项目有多个app, 当然通用的app也可以在多个项目中使用
3.启动服务器,出现这个报错,python manage.py migrate,解决报错
想让其他电脑也可以访问修改项目下面的settings.py
4.修改
ALLOWED_HOSTS = [‘*‘]
之后运行
[root@mytest project_yang]# python manage.py runserver 0.0.0.0:8000
安装成功
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
修改页面显示
在项目下面创建一个文件:
[root@mytest project_yang]# pwd
/myproduct/project_yang/project_yang
[root@mytest project_yang]# vim test.py
from django.http import HttpResponse def hello(request): return HttpResponse("Hello augustyang ! ")
修改urls.py
from django.conf.urls import url from . import test urlpatterns = [ url(r‘^$‘, test.hello), ]
再次启动
# python manage.py runserver 0.0.0.0:8000
安装django