我需要为模型上的字段翻译选项.我有这样的事情:
from django.utils.translation import ugettext as _
from django.db import models
class MyModel(models.Model):
TYPES = (
(1, _("Option one")),
(2, _("Option two"))
(3, _("Option three"))
)
type = models.CharField(max_length=50, choices=TYPES)
Run Code Online (Sandbox Code Playgroud)
在此之前,我在登录视图上有一个脚本:
request.session['django_language'] = request.POST.get("language")
Run Code Online (Sandbox Code Playgroud)
所以,问题是当django在MyModel上调用TYPES时,因为request.session ['django_language']不存在.
任何帮助将不胜感激.
谢谢...
我有两个这样的组件:
@Component({
selector: 'comp1',
template: `<h1>{{ custom_text }}</h2>`
})
export class Comp1 {
custom_text:string;
constructor(text:string) {
this.custom_text = text;
}
}
/*********************************************/
@Component({
selector: 'comp2',
directives: [Comp1],
template: `
<b>Comp 2</b>
<comp1></comp1>
`
})
export class Comp2 {
constructor() {
// ...
// How to send my own text to comp1 from comp2
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
是否有可能从把我自己的文字comp1来comp2?
是否可以从中获取comp1实例comp2?
谢谢.