mezzanine-project myproject python from django.db import models from mezzanine.pages.models import Page class MyPage(Page): content = models.TextField() python manage.py makemigrations python manage.py migrate python from django.shortcuts import render from .models import MyPage def my_page_view(request): my_page = MyPage.objects.get(id=1) return render(request, 'my_template.html', {'my_page': my_page}) html <html> <body> <h1>{{ my_page.title }}</h1> <p>{{ my_page.content }}</p> </body> </html> python from django.urls import path from .views import my_page_view urlpatterns = [ path('my-page', my_page_view, name='my_page'), ]


上一篇:
下一篇:
切换中文