【发布时间】:2021-11-26 06:26:25
【问题描述】:
我想准备一个输出书名、出版商和作者的网页,并想使用管理面板动态添加数据,但无法使用下面的代码来完成。请帮忙
models.py
from django.db import models
class researchpaper(models.Model):
title = models.CharField(max_length=200)
publication = models.CharField(max_length=200)
authors = models.CharField(max_length=200)
def __str__(self) -> str:
return self.title
views.py
def publications(request):
context = {
'researchposts': researchpaper.objects.all()
}
return render(request, 'lab/publications.html',context)
urls.py
path('publications', views.publications, name='publications'),
html文件
{% for paper in object_list %}
<tr>
<td>
<h5>2021</h5>
<p style="color: black;"><b>{{paper.title}}1. A minimal model for synaptic integration in simple neurons</b></p>
<p style="font-size: 14px;"><i>Physica D: Nonlinear Phenomena, 2021</i></p>
<p style="font-size: 14px;"><i>Adrian Alva, Harjinder Singh.</i></p>
</td>
<td><a href="#"
target="blank" style="color: dodgerblue;"><i class="ai ai-google-scholar-square ai-2x"
style="padding-right: 10px;"></i></a></td>
</tr>
<tr>
<td>
<hr>
</td>
</tr>
{% endfor %}
【问题讨论】:
标签: python django django-models django-views django-admin