我一直试图在一个简单的模型上过滤一个查询集但到目前为止没有运气.
这是我的模型:
class Country(models.Model):
COUNTRY_CHOICES = (
('FR', _(u'France')),
('VE', _(u'Venezuela')),
)
code = models.CharField(max_length=2, choices=COUNTRY_CHOICES)
def __unicode__(self):
return self.get_code_display()
Run Code Online (Sandbox Code Playgroud)
我想做的事情如下:
Country.objects.filter(get_code_display__icontains="france")
Country.objects.filter(code__display__icontains="france")
Country.objects.filter(get_code_display__icontains="france")
Run Code Online (Sandbox Code Playgroud)
但以上都没有奏效.如何过滤具有choices属性的字段?我认为被覆盖的__unicode__会有所帮助,但我想我错过了一些东西.
我正在尝试构建一个简单的文件,该文件依赖于使用 UMD 导出构建的库。
// main.ts
import { parseTree } from 'jsonc-parser';
const tree = parseTree('{ "name: "test" }');
console.log(tree);
Run Code Online (Sandbox Code Playgroud)
它编译得很好,但是 webpack 会抛出依赖错误:
哈希:85004e3e1bd3582666f5 版本:webpack 2.3.2 时间:959ms 资产大小 块 块名称 dist/bundle.js 61.8 kB 0 [emitted] main build/main.d.ts 0 bytes [emitted] [0] ./~/jsonc-解析器/lib/main.js 40.1 kB {0} [内置] [1] ./~/jsonc-parser/lib 160 字节 {0} [内置] [2] ./~/path-browserify/index.js 6.18 kB {0} [内置] [3] ./~/process/browser.js 5.3 kB {0} [内置] [4] ./src/main.ts 200 字节 {0} [内置] [5] ./ ~/vscode-nls/lib 160 字节 {0} [可选] [内置] [6] ./~/vscode-nls/lib/main.js 5.46 …