lebel_months = []
members_exps = []
for member in team.members.all():
qs = Profile.objects.expenses_per_month(member.user)
clr = color_picker()
member_qs = []
for exp in qs:
user = get_object_or_404(User, id=exp.user_id)
month = exp.month
summary = exp.sum
if month not in lebel_months and month is not None:
lebel_months.append(month)
if month is not None and summary is not None:
member_qs.append({
'user': user.username,
'clr': clr,
'month': month,
'summary': summary})
if member_qs:
members_exps.append(member_qs)
print(members_exps[0])
print(members_exps.first())
вывод: с [0] все работает
[{'user': 'serj', 'clr': '#71CABC', 'month': datetime.datetime(2020, 3, 1, 0, 0, tzinfo=<UTC>),
'summary': 128400}, {'user': 'serj', 'clr': '#71CABC', 'month': datetime.datetime(2020, 4, 1, 0, 0,
tzinfo=<UTC>), 'summary': 53500}]
с first ()
AttributeError: 'list' object has no attribute 'first'
Первый оператор print работает. Второе выражение print ловит ошибку. Что я делаю не так?