1
這是我第一次介紹'長'對象,並且我還沒有在Querysets &長對象的Django文檔中找到太多東西。我試圖將兩個不同的查詢加入列表,我可以通過電子郵件發送給每個用戶。Django:長對象屬性錯誤
有兩個問題 - 這是加入這些查詢的正確方法嗎?如果是這樣,我如何訪問profile.user.email
屬性而不碰到這個長對象錯誤?
email_list = []
for user in request.user.get_profile().followers.all():
email_list.append(user)
for profile in Profile.objects.filter(city=request.user.get_profile().city.id):
if not profile.user.id in email_list:
print type(profile.user.id)
email_list.append(profile.user.id)
錯誤:
AttributeError: 'long' object has no attribute 'email'
謝謝@Severio就是這樣。並感謝您解釋Long對象。我看到長整數,但不知道它們是一樣的。非常感激! – Emile