这是我的Django项目结构:
const data = [{
id: 1,
condition: 1,
helpers: [{id: 1, condition: null}, {id: 2, condition: 2}]
},{
id: 2,
condition: null,
helpers: [{id: 1, condition: 1}, {id: 2, condition: null}]
}];
const conds = [{
id: 1,
conditions: {
rules: ['test', 'foo']
}
},{
id: 2,
conditions: {
rules: ['#hashtag', 'foo']
}
}];
data.forEach(function(item) {
item.condition = conds.find(x => x.id === item.id).conditions.rules;
});
console.log(data);
在myfile.py里面,我想在task.py里面导入test()函数:
project/
app1/
static/
templates/
utils/
__init__.py
admin.py
forms.py
tasks.py
urls.py
views.py
myfile.py
控制台错误:
from . import tasks
tasks.test()
那怎么解决呢?
答案 0 :(得分:1)
尝试使用-
from .tasks import test
或
from app1 import tasks
tasks.test()