django steps EASY WAY

django 2.0
python 3.6

=========django steps EASY WAY===========

reference: https://djangoforbeginners.com/hello-world/

[1]django-admin startproject helloworld_project .

[2]python manage.py startapp pages

[3]INSTALLED_APPS ------>add app

# helloworld_project/settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'pages',
]

[4]app/views.py

# pages/views.py
from django.http import HttpResponse
def homePageView(request):
return HttpResponse('Hello, World!')

[5]app/urls.py
# pages/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.homePageView, name='home')
]

[6]project/urls.py
# helloworld_project/urls.py
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('pages.urls')),
]

[7]python manage.py runserver

[8]http://127.0.0.1:8000/

=========django steps EASY WAY===========

posted on 2018-02-14 15:16  rojas  阅读(112)  评论(0编辑  收藏  举报