模板
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<a href="hello">普通写法的hello</a>
<br>
<a href="{% url 'hello' %}">路由写法的hello</a>
</body>
</html>
路由
from django.urls import path, include, re_path
import blog.views
urlpatterns = [
path('', blog.views.get_index),
path('hello/', blog.views.hello_world),
path('hello/',blog.views.hello_world,name='hello'),
]
视图
def get_index(request):
return render(request, 'index.html')