我试图使用django-grappelli仪表板,管理界面给出了错误.
Django Version: 1.4.1
Exception Type: ImportError
Exception Value:
No module named dashboard
In template /.../lib/python2.7/site-packages/grappelli/dashboard/templates/admin/index.html, error at line 32
31 {% block content %}
32 {% grp_render_dashboard %}
33 {% endblock %}
Run Code Online (Sandbox Code Playgroud)
我可以在更改之前使用grappelli管理界面.采取的步骤是根据手册.我将这些添加到我的settings.py中
GRAPPELLI_INDEX_DASHBOARD = 'myproj.dashboard.CustomIndexDashboard'
...
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.request",
"django.core.context_processors.i18n",
'django.contrib.messages.context_processors.messages',
)
INSTALLED_APPS = (
'grappelli.dashboard',
'grappelli',
'django.contrib.admin',
...
Run Code Online (Sandbox Code Playgroud)
dashboard.py位于根目录(myproj)中.它里面有一堂课.
class CustomIndexDashboard(Dashboard):
myproj
??? admin
? ??? css
:
??? dashboard.py
??? grappelli
? ??? images
? ? ??? backgrounds
??? myapp
? ??? …Run Code Online (Sandbox Code Playgroud) 我从未尝试过Guide或其他DI库,但尝试使用Dagger from square for Android应用程序.它适用于Frgements,但不适用于POJO.该用户指南当做DI的一些知识,因为它没有更详细的解释.我该怎么做才能注入restAdapater我的POJO.如果我使用相同的代码进行字段注入,它可以在Fragment中使用.
public class MyApplication extends Application {
private ObjectGraph objectGraph;
@Override
public void onCreate() {
super.onCreate();
objectGraph = ObjectGraph.create(new DIModule(this));
}
public ObjectGraph objectGraph() {
return objectGraph;
}
public void inject(Object object) {
objectGraph.inject(object);
}
...
@Module(entryPoints = {
MainActivity.class,
.....,
Auth.class,
RestAdapter.class
})
static class DIModule {@Provides
@Singleton
public RestAdapter provideRestAdapter() {
return new RestAdapter.Builder().setServer(
new Server(Const.BASE_URL)).build();
}
}
}
Run Code Online (Sandbox Code Playgroud)
// POJO
public class Auth {
@Inject
RestAdapter restAdapater;
String Username; …Run Code Online (Sandbox Code Playgroud) D3 对选择的操作是通用的(如attr),它接受一个值,或一个传递数据的函数。我想根据当前选择设置一些样式参数。
来自文档:据我所知,以下场景将起作用
sel.style("stroke", "#000")
sel.style({"stroke": "#000", "stroke-width": "0.5"})
sel.style("stroke", function(d){return "#000"})
Run Code Online (Sandbox Code Playgroud)
但是,我需要的是获取 fn 返回的对象。
var fn = function(d){
return {"stroke": "#000", "stroke-width": "0.5"}
}
sel.style( fn)
Run Code Online (Sandbox Code Playgroud)
上面的例子,我不做任何事情d,但是,就我而言,我会根据d通过的情况做出决定。
我敢肯定,我可以做类似的事情,
sel.style(`fill`, fillFn)
sel.style(`stroke`, strokeFn)
Run Code Online (Sandbox Code Playgroud)
但是,我试图使我的代码通用,所以我可能不知道我需要提前设置什么样式。
编辑:
我也试过selection.property,,
sel.property("style", fn);
Run Code Online (Sandbox Code Playgroud)
但有错误
TypeError: Object [object Array] has no method 'property'
Run Code Online (Sandbox Code Playgroud)
但是,在同一个选择中,如果我这样做
sel.style({"stroke": "#000", "stroke-width": "0.5"})
Run Code Online (Sandbox Code Playgroud)
它工作正常。可能有什么问题?
我有通过凉亭安装jquery ver 2.现在试图获得最新的1.x(1.11.1).但是,它没有提供这种选择
bower install jquery --save
bower jquery#* cached git://github.com/jquery/jquery.git#2.1.0
bower jquery#* validate 2.1.0 against git://github.com/jquery/jquery.git#*
bower jquery#* new version for git://github.com/jquery/jquery.git#*
bower jquery#* resolve git://github.com/jquery/jquery.git#*
bower jquery#* download https://github.com/jquery/jquery/archive/2.1.1.tar.gz
bower jquery#* extract archive.tar.gz
bower jquery#* resolved git://github.com/jquery/jquery.git#2.1.1
bower jquery#>=1.8.0 cached git://github.com/jquery/jquery.git#2.1.1
bower jquery#>=1.8.0 validate 2.1.1 against git://github.com/jquery/jquery.git#>=1.8.0
Unable to find a suitable version for jquery, please choose one:
1) jquery#1.8.3 which resolved to 1.8.3 and is required by angular-file-upload#0.3.1
2) jquery#>=1.8.0 which resolved to 2.1.1 and is required …Run Code Online (Sandbox Code Playgroud) 如何统计Docker容器 我已经使用
docker run -d -P -v /Users/bsr:/usr/local/users --name test ubuntu
安装了虚拟盒子来宾添加程序并进行安装的方式创建了它
。但是,我不确定为什么我不能保持外壳运行。
bsr[~/tmp/web] $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cf620ff6c36a ubuntu:latest "/bin/bash" 2 hours ago Exited (0) 2 minutes ago test
8213c8d49842 nginx:latest "nginx" 3 hours ago Up About an hour 0.0.0.0:49154->80/tcp web
bsr[~/tmp/web] $ docker start test
test
bsr[~/tmp/web] $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cf620ff6c36a ubuntu:latest "/bin/bash" 2 hours ago Exited (0) 2 seconds ago …Run Code Online (Sandbox Code Playgroud) 我正在尝试在GORM中执行以下sql语句
select * from table1 where table1.x not in
(select x from table 2 where y='something');
Run Code Online (Sandbox Code Playgroud)
所以,我有两个表,需要找到表1中不在表2中的条目.在Grails中
def xx= table2.findByY('something')
def c = table1.createCriteria()
def result= c.list {
not (
in('x', xx)
)
}
Run Code Online (Sandbox Code Playgroud)
语法错了,我不知道如何在 sql逻辑中模拟.
作为一个学习点,如果有人也可以告诉我为什么grails/groovy中的减号( - )运算符不能与列表一起使用.我尝试单独获取x和y,并执行x.minus(y),但它不会更改列表.我在Grails列表上的Groovy上看到了一个解释- 没有用?,但我希望定义的列表是本地的.
非常感谢.
有没有办法在解析Json时指定类型,以便自动进行转换.
所以我有jsonData,x和y值需要是数字.所以,我能想到的唯一方法是循环和转换每个.有更好的逻辑,还是有效的方法?
var jsonData = '[{"x:"1", "y":"2"}, {"x:"3", "y":"4"}]'
var needed = [{x:1, y:2}, {x:3, y:4}]
var vals = $.parseJSON(jsonData);
//
var Coord = function(x, y){
this.x = x;
this.y = y;
}
var result = [];
function convert(vals) {
for (var i=0,l=vals.length; i<l; i++) {
var d = vals[i];
result.push(new Coord(Number(d.x), Number(d.y)));
};
}
Run Code Online (Sandbox Code Playgroud)
是否有与jQuery事件回调相关的特殊性.比如说,我在div元素上注册了mousedown事件回调,也在文档上注册了.如果我点击div会触发哪一个?注册顺序是否重要?或者特殊性(如css)很重要?
谢谢.
如果文件命名为*.html,则以下代码可以工作(在控制台中,您可以看到两个日志消息作为检测到的元素),但如果我命名为*.xhtml,则不会选择元素.为什么这些表现不一样?只有当类名包含在选择器中时才会出现问题,因此$("#cvs rect")在两种情况下均可使用,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Test</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</head><body>
<svg id="cvs" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 200 100" version="1.1" baseProfile="full">
<rect class="drag resize" x="50" y="30" width="50" height="30" />
<rect class="drag resize" x="5" y="5" width="90" height="50" />
</svg>
<script>
$(document).ready(function() {
$("#cvs rect.resize").each(function() {
console.log("selected");
});
});
</script>
</body></html>
Run Code Online (Sandbox Code Playgroud) 最近我一直在阅读有关javascript模式,以及如何使用模块模式来避免全局变量.当我查看d3.js 层次结构布局源代码时,我不确定下面是否有意.
d3.layout.hierarchy 是使用模块模式,但最后,我看到它外面的许多方法,我想这只适用于布局及其派生对象(分区,树..).
d3_layout_hierarchyRebind
d3_layout_hierarchyChildren
d3_layout_hierarchyValue
..
Run Code Online (Sandbox Code Playgroud)
这是故意的,还是应该在模块中捕获?