【发布时间】:2022-01-19 23:00:22
【问题描述】:
如果我从我的管理面板发布一首歌曲,我希望歌曲列表出现在模板中,我已经创建了一个允许我发布它的模型,但我不知道如何创建一个允许发布的视图要出现在模板中的歌曲,请问我该怎么做?
这是我的空视图 视图.py
from django.shortcuts import render
from .models import Audio
# Create your views here.
def index(request):
return render(request, 'index.html')
这是我创建的 models.py 模型.py
from django.db import models
# Create your models here.
class Audio(models.Model):
book_title = models.CharField(max_length=100, null=False, blank=False)
file = models.FileField(upload_to='file')
author = models.CharField(max_length=100, null=False, blank=False)
artist = models.CharField(max_length=100, null=False, blank=False)
【问题讨论】:
标签: python django templates django-views