34

I'm just trying to pull out each individual event from a list of events and perform an action on them. The code I currently have in my view is:

    user = request.user.get_profile()
    followed = user.eventList
    eL = [getEvent.getEvent(e_id) for e_id in followed]

First, I'm grabbing the currently logged in user, then looking at his eventList, then iterating over it. I get the above error. Think I may be missing some line?

4

1 回答 1

60

假设从错误eventList是一个多对多的字段,你需要使用.all()来获取相关的对象。多对多字段是一个管理器,因此您可以使用它来构造返回实际对象的查询集。

user = request.user.get_profile()
eL = user.eventList.all()
于 2013-07-18T19:41:20.910 回答