Answer the question
In order to leave comments, you need to log in
How to solve the problem with sending an email in django in production?
Good afternoon. Required behavior: an order is formed on the site, after placing the order it goes to the admin panel and is sent to the mail of the site owner. This behavior works correctly from under the Dzhang server, but does not want to send it from production.
Actually the piece of the view itself
def send_order_to_crm(order):
data = {
"client": {
"name": order.client.name,
"phone": order.client.phone,
"email": order.client.email
},
"info": {
"total": order.sum,
"created": order.created.strftime("%d.%m.%Y %H:%M")
},
"orders": [
]
}
for op in order.order_products.all():
data["orders"].append(
{
"name": op.product.title,
"description": op.product.desc,
"count": op.count,
"cost": op.product.cost,
"sum": op.sum,
}
)
print data
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post('http://crm.goeasyy.ru/api/v1/orders',
data=json.dumps(data),
headers=headers)
print r.text
return False
Answer the question
In order to leave comments, you need to log in
Why do you print to the console in production?
Output to the log at least.
Comment out or remove the lines with print - the error will disappear.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question