django-day1

1. Create Project
django-admin.py startproject devops

2, create APP

qiangsh@Dream ~/D/P/5/Django_day1> cd devops/
qiangsh@Dream ~/D/P/5/D/devops> python manage.py startapp hello
qiangsh@Dream ~/D/P/5/D/devops> tree hello

hello
├── __init__.py
├── admin.py
├── apps.py
├── migrations
│   └── __init__.py
├── models.py
├── tests.py
└── views.py

1 directory, 7 files

3, the global configuration file in the newly created registered APP

$ cat devops/settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'hello.apps.HelloConfig',
]

4, the code write processing logic (controller)

$ cat hello/view.py

# Create your views here.

from django.http import HttpResponse

def index(request):
    return HttpResponse("<p>Hello World,Hello, Django</p>")

5、

Guess you like

Origin blog.51cto.com/qiangsh/2422112