Hi Everyone,
I have a ForeignKey field that is always null on the Flex client. I
have tried using select_related(), but it's still null. Any idea what
I am doing wrong? In the following sample code, parentBlock is always
null on the Flex client:
File: BlockVO.py
from django.db import models
class Block(models.Model):
blockName = models.CharField(max_length=200)
blockLabel = models.CharField(max_length=200)
blockColor = models.PositiveIntegerField()
xBlockPos = models.IntegerField()
yBlockPos = models.IntegerField()
parentConnectionType = models.CharField(max_length=200,
blank=True, null=True)
parentBlock = models.ForeignKey('self', blank=True, null=True)
def __unicode__(self):
return self.blockLabel
File gateway.py
# To get all Blocks
def getBlocks():
return Block.objects.all().select_related()
File page.as
private function onResult_blocks(data:Object):void {
var answer : Array = ArrayUtil.toArray(data);
trace("Server returned " + answer.length.toString() + "
block(s)");
for each (var item:BlockVO in answer) {
if(null == item.parentBlock) {
trace("for bloc id=" + item.id +
"parentBlock is null");
} else {
trace("for bloc id=" + item.id +
"parentBlock_id=" +
item.parentBlock.id);
}
var newBlock : Block = new Block(workspace, false,
item.blockLabel, 0x66FF66, BlockSpec.REPORTER, null, item);
blocks.push(newBlock);
addChild(newBlock);
}
}
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.