Reference: HTTPS://DOCS.DJANGOPROJECT.COM/EN/1.9/INTRO/TUTORIAL01/
1. Go to the desired directory,
$ sudo django-admin startproject ProjectName
2. Start the server
Go to the manage.py directory.
$ sudo python manage.py runserver 0.0.0.0:8000
3. Create an App
1) Create
Enter the manage.py directory
$ sudo python manage.py startapp polls
Polls is the file name of the app
2) Modify View
Enter polls
$ sudo vi views.py
Add to
HttpResponseIndex(requestHttpResponse("Hello, World.") You ' re at the polls index. )
3) Create URL
Create urls.py under the polls file
polls/urls.py
$ sudo vi urls.py
Add to
From Django.conf.urls import URL
From. Import views
urlpatterns = [url (r ' ^$ ', views.index,name= ' index '),]
4) point to URL
Open mysite/mysite/urls.py (Note that this is a subfolder mysite,url.py already exists)
Add to
From Django.conf.urls import Url,include
From Django.contrib Import admin
urlpatterns = [url (r ' ^polls/', include (' Polls.urls ')), url (' ^admin/', admin.site.urls),]
(Regular expression: http://www.ziqiangxuetang.com/regexp/regexp-syntax.html)
5)
sudo python manage.py runserver
You can open it at the URL/polls.
Django (2): Launch and first app