E
E
Eugene2016-03-09 12:03:18
Django
Eugene, 2016-03-09 12:03:18

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

What else to add to fully understand the possible reasons for this, in my opinion, strange behavior?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2016-03-09
@dragonesis

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.

S
sim3x, 2016-03-09
@sim3x

At the beginning of the file# encoding: utf-8
? where is she

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question