我有模型订单
class Order(models.Model):
STATUS = (
('Pending', 'Pending'),
('Out for delivery', 'Out for delivery'),
('Delivered', 'Delivered'),
)
shop = models.ForeignKey(Shop, models.CASCADE, null=True)
customer = models.ForeignKey(Customer, models.CASCADE, null=True)
product = models.ForeignKey(Product, models.CASCADE, null=True)
quantity = models.CharField(max_length=30, null=True, )
date_created = models.DateTimeField(auto_now_add=True, null=True)
status = models.CharField(max_length=200, null=True, choices=STATUS, default='Pending')
note = models.CharField(max_length=1000, null=True)
当客户插入订单时,我如何向商店发送短信,然后商店收到短信,告知您有客户姓名的新订单。数量中的产品名称
客户模型
class Customer(models.Model):
user = models.OneToOneField(User, null=True, on_delete=models.CASCADE)
name = models.CharField(max_length=100, null=True, default='customer')
Phone = models.CharField(null=True, max_length=10)
店铺模型
class Shop(models.Model):
user = models.OneToOneField(User, null=True, related_name='shop', blank=True, on_delete=models.CASCADE)
name = models.CharField(max_length=70, null=True, default='shop', )
address = models.CharField(max_length=200, null=True)
Phone = models.CharField(null=True, max_length=10)
和我的订单views.py
def CreateOrder(request, shop_id, product_id):
customer = request.user.customer
shop = Shop.objects.get(id=shop_id)
product = Product.objects.get(id=product_id)
form = OrderForm()
quantity = request.POST.get('quantity')
note = request.POST.get('note')
if request.method == 'POST':
order = Order.objects.create(customer=customer, shop=shop,
product=product, quantity=quantity, note=note)
return redirect('CustomerOrder')