图像从部署到 heroku 的 django web 应用程序中消失
我正在开发一个 django 项目,使用 django rest 框架编写 rest API 以在 android 应用程序中使用它们,我的主要想法是在 django 中开发后端,在 android 中开发前端,项目部署在 heroku 上。我的应用程序包含一些带有商品图片的库存,问题是当我上传图片时它成功上传了图片但一段时间后或更具体地说是几个小时后图片自行消失。这是我的 setting.py 文件"""Django settings for forBirds project.Generated by 'django-admin startproject' using Django 3.0.6.For more information on this file, seehttps://docs.djangoproject.com/en/3.0/topics/settings/For the full list of settings and their values, seehttps://docs.djangoproject.com/en/3.0/ref/settings/"""import osimport dj_database_url# Buld paths inside the project like this: os.path.join(BASE_DIR, ...)BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))# Quick-start development settings - unsuitable for production# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/# SECURITY WARNING: keep the secret key used in production secret!SECRET_KEY = ''# SECURITY WARNING: don't run with debug turned on in production!DEBUG = TrueALLOWED_HOSTS = ['*']# Application definitionINSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'account', 'rest_framework', 'rest_framework.authtoken', 'Birds',]MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware',]ROOT_URLCONF = 'forBirds.urls'
查看完整描述