1 回答

TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個贊
正如 Marc 所定義的,我更新了代碼塊,如下所示?,F(xiàn)在它完美運(yùn)行了!
//Get func
func (c *EventController) Get() {
days := [7]string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}
m := make(map[string][]*models.Event)
for _, day := range days {
o := orm.NewOrm()
var events []*models.Event
num, err := o.QueryTable("events").Filter("day__name__exact", day).RelatedSel().All(&events)
fmt.Print("Day: ", day, " Count:", num, "\n")
if err != nil {
fmt.Printf("%d posts read\n", num)
}
m[day] = events
}
c.Data["json"] = m
// c.TplName = "events.tpl"
c.ServeJSON()
}
- 1 回答
- 0 關(guān)注
- 151 瀏覽
添加回答
舉報(bào)