- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
尝试将 .png 文件上传到管理图片表时出现错误:
SuspiciousFileOperation at /admin/products/productimage/add/ The joined path (/product/images/Laptop-Computer-5_copy.png) is located outside of the base path component (/images)
这是我的设置:
import os
# BASE_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)))
'''path settings for django==1.8'''
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
TEMPLATE_DIRS = (
#'/Users/jmitch/Desktop/seven/static/templates/',
os.path.join(os.path.dirname(os.path.dirname(BASE_DIR)), "static", "templates"),
)
# STATICFILES_FINDERS = (
# 'django.contrib.staticfiles.finders.FileSystemFinder',
# 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# #'django.contrib.staticfiles.finders.DefaultStorageFinder',
# )
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# 'DIRS': [BASE_DIR+"/templates", ],
'DIRS': [BASE_DIR + "/static/templates/", ],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.media',
'django.template.context_processors.media',
],
},
},
]
ENV_PATH = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
MEDIA_ROOT = os.path.join(ENV_PATH, '/images')
# MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'static', 'media')
# MEDIA_ROOT = '/Volumes/Storage/_codework/e_shop/static/media/product/images/'
STATIC_ROOT = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'static', 'static-only')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'static', 'static'),
)
# MEDIA_ROOT = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(BASE_DIR))), "static", "media")
MEDIA_URL = '/media/'
enter code here
但是当我在 MEDIA_ROOT 中添加“product/images”(在“product”之前没有斜线)发生错误:
SuspiciousFileOperation at /admin/products/productimage/add/ The joined path (/product/images/Laptop-Computer-5_copy.png) is located outside of the base path component (/Volumes/Storage/_codework/e_shop/product/images)
虽然出于测试目的,我将 product/images 文件夹的副本放在项目的根目录中。否则,当斜杠在 product('/product/images') 之前时,我会遇到该错误:
OSError at /admin/products/productimage/add/[Errno 13] Permission denied: '/product'
我已经更改了访问权限,例如 (MacOs):
chmod -R 777 /Volumes/Storage/_codework/e_shop/static/media/
和
chown -R K /Volumes/Storage/_codework/e_shop/static/media/
但没有任何帮助。什么问题?请指教。这个问题和我之前的问题有关please see
最佳答案
您进行了一些更改,但这些更改未与数据库同步。我在实现级别上搜索过它,这不是错误。确保您使用的是更新版本的 Pillow 和 image = models.ImageField(upload_to="whateverfolder/"。如果您使用的是 1.8 及以上版本,则使用“python manage.py makemigrations”进行同步。如果您使用的是 1.8 以下版本,请执行“python manage.py syncdb 你的问题就解决了。为了将来养成同步模型的习惯。
关于python - 可疑文件操作..加入的路径...位于基本路径组件之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33625173/
我想对 JOIN 进行特定的排序 SELECT * FROM (lives_in as t1 NATURAL JOIN preferences p1) l1 JOIN (lives_in t2 NAT
我正在努力解决一个查询。并想知道是否有人可以提供帮助。 我有一个标签表(服务请求票)和序列号表 从我的标签中我正在这样做 Select * from tag where tag.created BET
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 7 年前。 Improve this ques
我有两个表 tbl_user 和 tbl_lastchangepassword,如下所示 表 tbl_user id| name --------- 1 | user1 2 | user2 3 |
我有下一个问题 SELECT i.*, gu.* vs.* FROM common.global_users gu LEFT JOIN common.global_users_perms gup ON
我有一个电影表和一个投票表。用户为他们喜欢的电影投票。我需要显示按电影总票数降序排列的电影列表。我现在所拥有的有点作品。唯一的问题是它不显示 0 票的电影。 SELECT m.name, m.imdb
我有一个由这样的表组成的 mySql 数据库: 我如何(如果可能的话)使用 JOINS 从名称/周期表中获取结果?简单来说,它是如何工作的?我向菜鸟问题道歉。我对此很陌生。任何帮助将不胜感激。 最佳答
我需要查询单元先决条件的自引用关系。 我知道您需要使用两个联接,我是否选择我的列然后将其联接到自身? SELECT u.unit_code, u.name + ' is a prerequisi
我有两个实体,用户和友谊,它们看起来像: public class User { public int UserId { get; set; } (..
假设我有两个表: Table A ProdID | PartNumber | Data... 1 | ABC-a | "Data A" 2 | (null) |
说我有这个数据, (df <- data.frame( col1 = c('My','Your','His','Thir'), col2 = c('Cat','Dog','Fish','Dog')))
我有两个这样的数组,实际上这是从两个不同的服务器检索的 mysql 数据: $array1 = array ( 0 => array ( 'id' => 1, 'n
我的数据库中有以下表格 CREATE TABLE [author_details] ( [_id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, [name
我正在努力使用一个相当简单的 sql select 语句的 join/where 子句。 我正在尝试从 tb1 中检索产品信息列表,其中 where 条件位于 tbl2 中,但这必须由三个不同的列连接
我正在寻找以下功能: Applicative f => f (f a) -> f a Hoogle给我看join : >:t join join :: Monad m => m (m a) -> m
我有两个“表”,分别是 USER 和 CONGE。在表“CONGE”中,我插入了用户的 ID。但是我不知道如何根据用户的id显示用户的休假。 我想根据id发布“Congé”。 { "conge"
我们有一个具有(简化)结构的文档,如Elasticsearch所示: { _id: ..., patientId: 4711, text: "blue" } { _id: ..., patientId
这两个sql语句有什么区别 a) 从 T1,T2 中选择 *,其中 T1.A=T2.A ; b) 从 T1,T2 中选择 *,其中 T2.A=T1.A ; 在这两种情况下我得到相同的输出,这两种语句之
我想做一个简单的连接,只是比较两个表中的 ID.. 我有我的组表,包含; 身份证 姓名 等.. 我的 GroupMap 表包含; 身份证 组号 元素编号 我的查询采用 GroupMap.ItemID
所以我有一组主要数据,如下所示: value_num code value_letter 1 CDX A 2 DEF B
我是一名优秀的程序员,十分优秀!