我在Django应用程序中有这样一个模型。我想只绘制该模型的一个字段并将它们放在视图中。我的以下解决方案不起作用:
obj = Text.objects.get(subsID)
我的模型
result = braintree.Subscription.create({
"payment_method_token": payment_method_token,
"plan_id": "67mm"
})
subscription_id = result.subscription.id
class Text(models.Model):
title = models.CharField(max_length=255)
text = models.TextField()
date_from = models.DateTimeField('date from', blank=True, null=True)
date_to = models.DateTimeField('date to', blank=True, null=True)
subsID = models.CharField(default=subscription_id, max_length=255)
def __unicode__(self):
return self.title
我的看法
def get_history(request):
subscription_id = Text.objects.filter(subsID)
history = braintree.Subscription.find(subscription_id)
return render(request, "sheet/history.html", {"history": history})
Text.objects.filter(subsID)
"中的subsID
是什么? - itzMEonTV