数据库设计(models.py)
class Music(models.Model):
""" 音乐 """
name = models.CharField(verbose_name="音乐名字", max_length=32)
singer = models.CharField(verbose_name="歌手", max_length=32)
# 本质上数据库也是CharField,自动保存数据。
music = models.FileField(verbose_name="音频", max_length=128)
链接(urls.py)
# 音频上传
path('music/upload/', music.music_upload),
path('music/add/', music.music_add),
处理代码(music.py)
from django.shortcuts import render, redirect
from app01 import models
def music_upload(request):
queryset = models.Music.objects.all()
return render(request, 'music_upload.html', {'queryset': queryset})
from app01.utils.bootstrap import BootStrapModelForm
标签:name,models,音频,queryset,upload,Django,music,上传,verbose
From: https://blog.csdn.net/qq_43580271/article/details/140505774