(二)django--带APP的网站

前端之家收集整理的这篇文章主要介绍了(二)django--带APP的网站前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.打开终端,进入到django项目,创建APP应用:python manage.py startapp news

 

 2.在settings.py中进行注册

 

 3.在news下新建views.py,和urls.py。

views.py:

from django.shortcuts import render

# Create your views here.
from django.http  HttpResponse
def index(request):
    return HttpResponse("hello world")

urls.py:

from django.contrib  admin
from django.urls  path
from .  views

urlpatterns = [
    path('',views.index),]

4.在myweb中的urls.py

 path,include
from news  urls

urlpatterns ='admin/'

5.启动服务

python manage.py runserver

 

原文链接:/django/991024.html

猜你在找的Django相关文章