Ошибка:
AttributeError at /orders/
'NoneType' object has no attribute 'add'
Сам код:
def create(self, validated_data):
address_data = dict(validated_data.pop('address'))
print address_data
address = Address.objects.create(**address_data)
instance = Order.objects.create(address=address, **validated_data)
session_id = self.context['request'].session.session_key
burger_ids = SessionOrder.objects.filter(session_id=session_id)
for item in burger_ids:
burger = Burger.objects.get(id=item.burger_id)
instance.burgers.add(burger)
return instance
Проверял, instance точно не None.