我试图通过对另一个类属性执行操作来动态设置类属性.我的代码是这样的
class LastActionModel(BaseModel):
"""
Provides created_by updated_by fields if you have an instance of user,
you can get all the items, with Item being the model name, created or updated
by user using user.created_items() or user.updated_items()
"""
created_by = models.ForeignKey(
settings.AUTH_USER_MODEL, blank=True, null=True,
related_name = lambda self:'%s_%s' %('created', \
self._meta.verbose_name_plural.title().lower())
)
updated_by = models.ForeignKey(
settings.AUTH_USER_MODEL, blank=True, null=True,
related_name = lambda self:'%s_%s' %('updated', \
self._meta.verbose_name_plural.title().lower())
)
class Meta:
abstract = True
Run Code Online (Sandbox Code Playgroud)
这是为了动态设置相关名称,以便对于类Item和用户'user',我可以轻松调用user.created_items.all().
这给了我错误
super(ForeignObject, self).contribute_to_class(cls, name, virtual_only=virtual_only)
File "/home/pywebapp/venv/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 113, …Run Code Online (Sandbox Code Playgroud) 我正在使用python 2.7.10构建一个新的amazon实例作为默认值.在我运行了我的机器配置脚本并且真相到来之后,芹菜给了我一个导入,所以我调试了问题给billard.
包看起来是正确的路径,即
sudo find -name "billiard"
./srv/ia-live/lib64/python2.7/dist-packages/billiard
Run Code Online (Sandbox Code Playgroud)
其中ia-live是我的virtualenv的道路.检查via python virtualenv可执行文件中的路径
import sys
sys.path
['',
'/srv/ia-live/bin',
'/srv/ia-live/src/django-devserver-redux-master',
'/usr/lib/python2.7',
'/srv/ia-live/local/lib64/python2.7/site-packages',
'/srv/ia-live/local/lib/python2.7/site-packages',
'/srv/ia-live/lib64/python2.7',
'/srv/ia-live/lib/python2.7',
'/srv/ia-live/lib64/python2.7/site-packages',
'/srv/ia-live/lib/python2.7/site-packages',
'/srv/ia-live/lib64/python2.7/lib-dynload',
'/srv/ia-live/local/lib/python2.7/dist-packages',
'/srv/ia-live/local/lib/python2.7/dist-packages',
'/srv/ia-live/lib/python2.7/dist-packages',
'/usr/lib64/python2.7',
'/usr/lib/python2.7',
'/srv/ia-live/local/lib/python2.7/dist-packages/IPython/extensions',
'/home/ec2-user/.ipython']
Run Code Online (Sandbox Code Playgroud)
这似乎是正确的,但当我这样做
import billiard
ImportError: No module named billiard
Run Code Online (Sandbox Code Playgroud)
我不明白为什么会有问题
我正在尝试获得自定义类型的观察值
export interface ConfigurationState {
outlet_id: number;
api_key: string;
}
Run Code Online (Sandbox Code Playgroud)
在我的组件中
@Component({
selector: 'retail-root',
templateUrl: './root.component.html',
styleUrls: ['./root.component.scss']
})
export class RootComponent implements OnInit {
public config$: Observable<ConfigurationState>;
constructor(private store: Store<fromRoot.State>) {
this.config$ = this.store.select(fromRoot.getConfigState);
this.config$.subscribe(data => console.log(data));
}
ngOnInit() {
console.log(this.config$);
this.store.dispatch(new configActions.GetConfig());
}
}
Run Code Online (Sandbox Code Playgroud)
当我使用如下
{{ config$ | async }}
Run Code Online (Sandbox Code Playgroud)
它给了我,[object Object]但是如果订阅了,this.config$.subscribe(data => console.log(data));我可以在控制台中得到正确的对象。
谁能帮忙?
我想用django使用gulp-useref.我的所有注入脚本都工作正常,注入后进行手动路径更新,但现在我想连接我注入的脚本.这是我的HTML
<!-- build:css({compile/serve,src}) styles/vendor.css -->
<!-- bower:css -->
<link rel="stylesheet" href="{{ STATIC_URL }}dash/bower_components/angular-material/angular-material.css" />
<link rel="stylesheet" href="{{ STATIC_URL }}dash/bower_components/nvd3/src/nv.d3.css" />
<!-- endbower -->
<!-- endbuild -->
<!-- build:css({compile/serve,src}) styles/app.css -->
<!-- inject:css -->
<link rel="stylesheet" href="{{ STATIC_URL }}dash/compile/serve/styles/main.css">
<!-- endinject -->
<!-- endbuild -->
Run Code Online (Sandbox Code Playgroud)
和
<!-- build:js(src) scripts/vendor.js -->
<!-- bower:js -->
<script src="{{ STATIC_URL }}dash/bower_components/angular/angular.js"></script>
<script src="{{ STATIC_URL }}dash/bower_components/angular-animate/angular-animate.js"></script>
<script src="{{ STATIC_URL }}dash/bower_components/angular-cookies/angular-cookies.js"></script>
<script src="{{ STATIC_URL }}dash/bower_components/angular-touch/angular-touch.js"></script>
<script src="{{ STATIC_URL }}dash/bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="{{ STATIC_URL }}dash/bower_components/angular-resource/angular-resource.js"></script>
<script src="{{ STATIC_URL }}dash/bower_components/angular-route/angular-route.js"></script> …Run Code Online (Sandbox Code Playgroud) django ×2
amazon-ec2 ×1
angular ×1
celery ×1
gulp ×1
gulp-useref ×1
ngrx ×1
ngrx-store ×1
python ×1
python-2.7 ×1
virtualenv ×1