【发布时间】:2020-07-24 13:43:08
【问题描述】:
忽略标题。我在管理页面上显示写入和保存的文本时遇到问题。 我只是创建名称为 about 的新应用程序。使用命令 python manage.py startapp 关于 以下所有文件都在这个应用程序中。
模型.py
from django.db import models
# Create your models here.
class About(models.Model):
title = "About me"
discription = models.TextField()
def __str__(self):
return self.title
admin.py
from django.contrib import admin
from .models import About
# Register your models here.
admin.site.register(About)
# Register your models here
views.py:
from django.shortcuts import render
from django.http import HttpRequest
from .models import About
# Create your views here.
def about(request):
abouts = About.objects.all()
return render(request, 'about/about.html', {'abouts': abouts})
urls.py
from django.urls import path
from . import views
app_name = 'about'
urlpatterns = [
path('', views.about, name='about'),
]
关于.html
<p style="color: white;">{{ abouts.discription }}</p>
问题是在描述里面写的文字没有显示在 about.html 页面上。请帮帮我。
【问题讨论】:
标签: python django django-models django-views django-admin