这可能不相关,但只是想问,
如果一个对象从视图传递到模板,并且在模板中我将能够查询多个到多个字段
型号代码:
class Info(models.Model):
xls_answer = models.TextField(null=True,blank=True)
class Upload(models.Model):
access = models.IntegerField()
info = models.ManyToManyField(Info)
time = models.CharField(max_length=8, null=True,blank=True)
error_flag = models.IntegerField()
def __unicode__(self):
return self.access
Run Code Online (Sandbox Code Playgroud)
浏览次数:
// obj_Arr contains all the objects of upload
for objs in obj_Arr:
logging.debug(objs.access)
logging.debug(objs.time)
return render_to_response('upload/new_index.html', {'obj_arr': obj_Arr , 'load_flag' : 2})
Run Code Online (Sandbox Code Playgroud)
在模板中,因为我们传递对象,所以可以解码多对多的字段
谢谢..