我将我的一个模型转储到一个灯具时使用--natural选项,这样在部署时我不会遇到Content_typ ID问题.结果在这里:
{
"pk": 1,
"model": "seo.opportunitymetadatamodel",
"fields": {
"_content_type": [
"opportunity",
"jobopportunity"
],
"og_description": "",
"description": "",
"title": "test",
"keywords": "",
"og_title": "",
"heading": ""
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试加载夹具时,我收到以下错误:
Problem installing fixture 'seo/fixtures/initial_data.json': Traceback (most recent call last):
File "/Users/xx/dev/envs/xx/lib/python2.6/site-packages/django/core/management/commands/loaddata.py", line 167, in handle
for obj in objects:
File "/Users/xx/dev/envs/xx/lib/python2.6/site-packages/django/core/serializers/json.py", line 38, in Deserializer
for obj in PythonDeserializer(simplejson.load(stream), **options):
File "/Users/xx/dev/envs/xx/lib/python2.6/site-packages/django/core/serializers/python.py", line 84, in Deserializer
Model = _get_model(d["model"])
TypeError: string indices must be integers, not str
Run Code Online (Sandbox Code Playgroud)
好像该方法不接受要加载的字符串.我错过了什么?
我正在使用
$('#test').dialog('destroy');
Run Code Online (Sandbox Code Playgroud)
但它似乎在页面上留下了一些自动创建的元素,我需要删除对话框在dom中闲置的所有可能元素,这可能吗?
我想创建一个方法,通过我给该方法的参数抛出特定的异常。我有 3 个用户定义的异常,因此我不想每次使用它们时都抛出它们,而是想创建一个处理它的方法,所以我用我的方法给出的参数就是我想要抛出的异常,但是我该怎么做去做?
我想做这样的事情,但我不太确定该怎么做。
private void ExceptionMethod(custom exception)
{
try
{
//code that might fail
}
catch(exception ex)
{
throw new exception given by parameter(parameters from the exception);
}
}
Run Code Online (Sandbox Code Playgroud)