0x00 django -- creating your first django project
1.preparatory work
python3: we will use python 3.5 to develop this project
pycharm: install pycharm professional on your computer--->Pycharm downloads
linux: we will develop this project on linux
django: pip3 install django
2.use pycharm IDLE to start your project
open your pycharm and create a django project
you will get a project
3.modify the setting file ~/djangoCarl/settings.py
ALLOWED_HOSTS = [
'127.0.0.1',
'www.exampleCarlBenjamin.com'
]
4.create the index.html ~/templates/index.html like that
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello Django</title>
</head>
<body>
<h1>Hello Django</h1>
</body>
</html>
5.modify your views ~/application/views.py like that
# coding=utf-8
from django.shortcuts import render
# Create your views here.
def application(request):
return render(request, 'index.html')
6.modify your urls ~/djangoCarl/urls.py like that
from django.conf.urls import url
from django.contrib import admin
from application.views import application
urlpatterns = [
url(r'$', application, name='application'),
url(r'^admin/', admin.site.urls),
]
7.cd to your workspace and
python3 manage.py runserver
8.You will see 127.0.0.1:8000
9.Now you complete your first project of django
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。