19
loading...
This website collects cookies to deliver better user experience
$ cd django_project
django_project $ source project_venv/bin/activate
django_project (project_venv) $
django_project (project_venv) $ python manage.py startapp app
django_project/
project_venv/
project/
app/
migrations/
__init__.py
__init__.py
admin.py
apps.py
models.py
tests.py
views.py
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'app'
]
from django.shortcuts import render
+from django.http import HttpResponse
+def index(request):
+ return HttpResponse("Hello, World!")
django_project (project_venv) $ cd app/
app (project_venv) $ touch urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
. . .
from django.contrib import admin
-from django.urls import path
+from django.urls import include, path
urlpatterns = [
+ path('', include('app.urls')),
path('admin/', admin.site.urls),
]
$ python manage.py runserver
django-admin startproject project
in the previous Django tutorial. And is technically the first user app you installed for your project.