我有一个Angular组件,它可以CatalogService注入一个服务:
export class CatalogListComponent implements OnInit {
catalog$: Observable<MovieResponseItem[]>;
constructor(private catalogService: CatalogService) {}
ngOnInit() {
this.catalog$ = this.catalogService.userCatalog;
}
}
Run Code Online (Sandbox Code Playgroud)
此服务返回Observable<MovieResponseItem[]>on属性userCatalog:
@Injectable()
export class CatalogService {
get userCatalog(): Observable<MovieResponseItem[]> {
return this._userCatalogSubject.asObservable();
}
}
Run Code Online (Sandbox Code Playgroud)
这MovieResponseItem只是一个简单的界面:
export interface MovieResponseItem {
title: string;
}
Run Code Online (Sandbox Code Playgroud)
现在我想迭代这些项目并显示一个加载动画,同时目录查询底层服务的数据(这需要一些时间) - 这是有效的.这是使用的模板:
<div *ngIf="(catalog$ | async)?.length > 0; else loading">
<ng-container *ngFor="let item of catalog$ | async">
<div>{{item.title}}</div>
<ng-container>
</div>
<ng-template #loading>loading animation...</ng-template>
Run Code Online (Sandbox Code Playgroud)
这显然会在异步等待数据时显示#loading模板.如果observable返回数据,则迭代目录值.
但现在我想把它分成这种行为:
我怎么能得到这个?从我在类似帖子上看到的,没有人试图实现这一点(或者我没有找到它). …
在django管理员中,您可以为ModelAdmin设置search_fields,以便能够搜索那里给出的属性.我的模型类有一个属性不是真正的模型属性,意味着它不在数据库表中.该属性涉及另一个数据库表,该表不通过关系绑定到当前模型.但我希望能够搜索它,所以我必须以某种方式自定义管理站点创建的查询,以便在搜索字段填满时进行过滤 - 这是否可能,如果,如何?我可以查询我的自定义属性的数据库表,然后返回适合搜索的模型类的ID.然后,正如我所说,这必须流入管理站点搜索查询.
谢谢!
我试图理解以下场景:
Gateway Timeout在一段时间后响应我想工人的重新启动并没有真正发生,或者该机制被负载阻塞了?我想了解解决此问题的方法。
谁能解释这里发生了什么?非常感谢!
PS:我绑定使用gunicorn 18.0,目前无法使用更新版本。
这是我使用的配置。
nginx:
# nginx
upstream gunicorn_app {
server 127.0.0.1:8100;
}
server {
listen 443 ssl;
...
# skipping static files config
...
location @proxy_gunicorn_app {
proxy_read_timeout 1800;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto …Run Code Online (Sandbox Code Playgroud) 我们正在使用 Selenium 和 django-selenium (SeleniumTestCase) 的 Python 绑定进行 Selenium 测试。在我们测试的页面上,有几秒钟延迟后创建的 HTML 元素。所以我们要等他们,然后继续测试。等待本身有效,但等待调用后的每个命令都失败:
class SomeTestCase(SeleniumTestCase):
def test_something(self):
... (some testing code that works)
self.driver.wait_element_present('span.available') # this works
self.driver.wait_element_present('span.connected') # this works, too
self.driver.find_element_by_css_selector('body') # this fails
Run Code Online (Sandbox Code Playgroud)
我调试了 selenium 代码,发现“find_element_by_css_selector”在内部向 selenium 服务器发布了一个 HTTP 请求(就像每个“检查 xxx 是否存在”命令一样):
http://127.0.0.1:42735/hub/session/<session-id>/element
Run Code Online (Sandbox Code Playgroud)
但是此请求返回状态代码 500 和此响应文本:
{
"status": 13,
"value": {
"message": "JSON.parse: unexpected non-digit",
"stackTrace": [
{
"methodName": "Dispatcher.executeAs/<",
"fileName": "file:///tmp/tmpnUT34U/extensions/fxdriver@googlecode.com/components/driver_component.js",
"lineNumber": 7354
},
{
"methodName": "Resource.prototype.handle",
"fileName": "file:///tmp/tmpnUT34U/extensions/fxdriver@googlecode.com/components/driver_component.js",
"lineNumber": 7516
},
{
"methodName": "Dispatcher.prototype.dispatch",
"fileName": "file:///tmp/tmpnUT34U/extensions/fxdriver@googlecode.com/components/driver_component.js", …Run Code Online (Sandbox Code Playgroud) 你好 - 今天发生了一个奇怪的问题:
我在Django中有一个modle类,并为它添加了一个自定义属性,它不能保存到数据库中,因此不代表模型结构:
class Category(models.Model):
groups = models.ManyToManyField(Group)
title = defaultdict()
Run Code Online (Sandbox Code Playgroud)
现在,当我在shell中或编写测试时,我会执行以下操作:
c1 = Category.objects.create()
c1.title['de'] = 'german title'
print c1.title['de'] # prints "german title"
c2 = Category.objects.create()
print c2.title['de'] # prints "german title" <-- WTF?
Run Code Online (Sandbox Code Playgroud)
似乎"头衔"具有全球性.如果我将标题更改为一个简单的字符串,它按预期工作,所以它必须对dict做一些事情?我也尝试将title设置为属性:
title = property(_title)
Run Code Online (Sandbox Code Playgroud)
但这也行不通.那么,我该如何解决这个问题呢?先感谢您!
编辑:
以下是基本问题的意图,可以根据需要更好地了解整个周围的环境:在我们的模型结构中,我们有一个存储翻译的模型类.此类与所有其他具有相互关系的类不绑定.翻译类存储翻译的值,语言密钥,翻译密钥以及翻译所属的包和类.某些模型类可以具有可以翻译成不同语言的属性.这些属性没有映射到django模型结构中,因为这在我们看来并不是真正可能的.每个具有可翻译属性的类,我们称之为translatables,可以具有一个或多个这些属性.那是翻译的关键所在.例如,如果存在具有可翻译属性的类别类别"
django ×3
python ×3
angular ×1
async-await ×1
class ×1
django-admin ×1
gunicorn ×1
high-load ×1
nginx ×1
selenium ×1