Article From:https://www.cnblogs.com/lenny0210/p/9734537.html

1.Create app

1.1Stop running server first.

python manage.py startapp todolist (todolistApp name)

1.2

Run the server again

#Choose a good text editor, refer to another essay Sublime Text.

 

2.Registration app tells the server that app has been created.

In settings.py

installed_appAdd a row to the app name.

‘todolist’,

 

3.Create template folder for web page template

todolistRight click the new folder, named templates.

 

4.Create a home page

4.1

Create a new file –> home.html under the Templates folder

4.2

Create HTML template –> enter, then press tab key to complete.

 

5.Web site related websites

5.1

Setting up URL distribution in general routing urls.py

from django.contrib import admin
from django.urls import path, include
import todolist.urls

Import include —-> why?

Create sub routing urls.py in app

And divide the route into the general route.

5.2Controlling web address association in urls.py

from django.urls import path, include
from . import views   #why?

urlpatterns = [

path(”, views.home,)
]                                    

5.3Control pages in views function

def home(request):
return render(request, “home.html”)

 

Link of this Article: The use of Django

Leave a Reply

Your email address will not be published. Required fields are marked *