嘿,我有这样的模特:
class Galleries(models.Model):
creation_date = models.DateTimeField()
name = models.CharField(max_length=255, unique=True)
gallery_type = models.ForeignKey(Categories)
class Categories(models.Model):
handle = models.CharField(max_length=255, unique=True)
class Values(models.Model):
category = models.ForeignKey(Categories)
language = models.CharField(max_length=7)
category_name = models.CharField(max_length=50)
Run Code Online (Sandbox Code Playgroud)
现在,我只想从画廊开始,达到类别的价值.例如:galleries = Galleries.objects.get(id=1).现在我希望通过使用这个"画廊"对象以某种方式达到价值......用特定语言获得价值会好得多......我想念Django ORM的技能,所以如果可以,请指点我docs或给出一些代码示例.谢谢!
我正在使用MultiMap mixin的可变HashMap,并注意到该map.add方法现已弃用:
val fieldTokenMap = new HashMap[String, scala.collection.mutable.Set[Int]] with MultiMap[String, Int]
// ...
fieldTokenMap add (token, docId)
Run Code Online (Sandbox Code Playgroud)
我基本上将字符串或标记映射到id列表.我是否应该在Scala中使用Map和MultiMap?
谢谢.
我在分析我的崩溃日志时遇到问题.当我点击应用程序图标启动应用程序时,iPhone有时会崩溃.该应用已在后台"运行",但它不活跃.这是符号化的崩溃日志:
Thread 0 Crashed:
0 libobjc.A.dylib 0x33479470 objc_msgSend + 28
1 CoreLocation 0x3436f68e -[CLLocationManager onClientEvent:supportInfo:] + 98
2 CoreLocation 0x3436f804 OnClientEvent + 16
3 CoreLocation 0x3436b522 CLClientInvokeCallback(__CLClient*, CLClientEvent, __CFDictionary const*) + 42
4 CoreLocation 0x3436cf74 CLClientHandleDaemonDataRegistration(__CLClient*, CLDaemonCommToClientRegistration const*, __CFDictionary const*) + 668
5 CoreLocation 0x3436d4c8 CLClientHandleDaemonData(__CFMessagePort*, long, __CFData const*, void*) + 212
6 CoreFoundation 0x33a813fe __CFMessagePortPerform + 242
7 CoreFoundation 0x33a556f8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
8 CoreFoundation 0x33a556bc __CFRunLoopDoSource1 + 160
9 CoreFoundation 0x33a47f76 __CFRunLoopRun + 514
10 CoreFoundation 0x33a47c80 CFRunLoopRunSpecific …Run Code Online (Sandbox Code Playgroud) 我是使用OpenGL的新手,正在尝试使用jogl.我能够毫无问题地绘制三角形,但是当我尝试绘制四边形(在许多教程中使用)时,eclipse一直告诉我GL.GL_QUADS无法解决.
gl.glBegin(GL.GL_QUADS);
Run Code Online (Sandbox Code Playgroud)
不知道我做错了什么.
谢谢,
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.*;
import javax.media.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.*;
public class SimpleScene implements GLEventListener {
public static void main(String[] args) {
GLProfile glp = GLProfile.getDefault();
GLCapabilities caps = new GLCapabilities(glp);
GLCanvas canvas = new GLCanvas(caps);
final Frame frame = new Frame("AWT Window Test");
frame.setSize(300, 300);
frame.add(canvas);
frame.setVisible(true);
// by default, an AWT Frame doesn't do anything when you click
// the close button; this bit of code will terminate the program when
// …Run Code Online (Sandbox Code Playgroud) 当试图转换byte[]的Camera.onPreviewFrame到Bitamp用BitmapFactory.decodeByteArray给我一个错误SkImageDecoder::Factory returned null
以下是我的代码:
public void onPreviewFrame(byte[] data, Camera camera) {
Bitmap bmp=BitmapFactory.decodeByteArray(data, 0, data.length);
}
Run Code Online (Sandbox Code Playgroud) 假设以下单身人士:
public class Test{
private static volatile Test test = null;
private static int test_int = 0;
private static String test_string = "test";
public int getInt(){
return test_int;
}
public String getString(){
return test_string;
}
private static Test getInstance(){
if(test == null){
synchronized(Test.class){
if(test == null)
test = new Test();
}
}
}
Run Code Online (Sandbox Code Playgroud)
通过声明单例实例Test是volatile,test_int和test_string也被认为是volatile,或者它们是否必须声明为?我想通过使类本身具有Volatile,那么该类下的所有东西都会变得不稳定......但是我不确定这一点.提前谢谢.
我想透视和加入从3个表中选择
ID Name value
---------------------------
1 a1 32116580
2 a2 50785384
3 a3 54327508
4 a4 61030844
Run Code Online (Sandbox Code Playgroud)
ID Name value
---------------------------
1 x11 61326085092
2 x12 80368184260
3 x13 83023398776
4 x14 91144307692
5 x22 95486535484
6 x23 90357090612
7 x24 100588807668
8 x33 707811916752
9 x34 93128452928
10 x44 84566653668
Run Code Online (Sandbox Code Playgroud)
ID Name value
---------------------------
1 q1 61326085092
2 q2 95486535484
3 q3 707811916752
4 q4 84566653668
Run Code Online (Sandbox Code Playgroud)
column1 column2 column3 column4
--------------------------------------------------------------------------
a1*a1/(q1+q1+x11) a1*a2/(q1+q2+x12) a1*a3/(q1+q3+x13) a1*a4/(q1+q4+x14) …Run Code Online (Sandbox Code Playgroud) 我需要在类的大多数函数中访问外部php文件的一些变量.我正在以下列方式访问(它工作正常)
class test{
function a(){
global $myglobalvar ;
..
..
}
function b(){
global $myglobalvar ;
..
..
}
function c(){
global $myglobalvar ;
..
..
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法可以在类的所有函数中访问$ myglobalvar而不在每个函数中声明?我确实读过它可以通过在类的构造函数中只声明一次来完成,但我不知道该怎么做.谢谢你的帮助.
在"Back UP"中我只得到一个bak文件,但我想创建.sql文件