'How can I export a function return in Django
I have a function called on_loading_booking_deal return a dic and I am interested to use the amount key and I want to export it to use it in another file
@receiver(loading_deal, sender=Booking)
def on_loading_booking_deal(deal_id: str, load_company: bool = False, **kwargs):
deal = get_deal(deal_id)
if not deal:
return None
formatted_deal = {
'id': deal_id,
'amount': get_entity_property(deal, 'amount'),
'occupational_use': get_entity_property(deal, 'occupational_use')
}
contact = None
if len(deal['associations']['associatedVids']) > 0:
contact = get_contact(deal['associations']['associatedVids'][0])
if not contact:
logger.warning("Unable to load hubspot contact")
if contact:
formatted_deal['contact'] = {
'first_name': get_entity_property(contact, 'firstname'),
'last_name': get_entity_property(contact, 'lastname'),
'email': get_entity_property(contact, 'email'),
'type_of_business_model': get_entity_property(contact, 'type_of_business_model')
}
if load_company:
company = None
if len(deal['associations']['associatedCompanyIds']) > 0:
company = get_company(deal['associations']['associatedCompanyIds'][0])
if not company:
logger.warning("Unable to load hubspot company")
if company:
formatted_deal['company'] = {
'name': get_entity_property(company, 'name')
}
print(f"Loaded deal {formatted_deal['amount']}")
return formatted_deal ## I want to export this return into another folder/file
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
