【发布时间】:2019-11-15 17:55:10
【问题描述】:
我是 django 的新手。我想在 html 模板文件中的特定天数或周数后获取日期。
我的模板文件代码:
{% for factors in c.factor %}
{% for factor_details in factors.factor_values %}
{{factor_details.id}}
{{factor_details.factor_value}}
# here this is given date {{order_detail.oderdate}} and this is number of days and weeks {{factor_details.factor_value}}.
{% endfor %}
{% endfor %}
订购型号:
class Order(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True,on_delete=models.CASCADE)
order_no = models.CharField(max_length=120, blank=True) # AB31DE3
shipping_address = models.ForeignKey(Addresses, related_name="shipping_address",null=True, blank=True,on_delete=models.CASCADE)
billing_address = models.ForeignKey(Addresses, related_name="billing_address",null=True, blank=True,on_delete=models.CASCADE)
cart = models.ForeignKey(Cart,on_delete=models.CASCADE)
shipping_total = models.DecimalField(default=0.00, max_digits=65, decimal_places=2)
totalamount = models.DecimalField(default=0.00, max_digits=65, decimal_places=2)
stripe_id = models.CharField(max_length=120, blank=True)
payment_status = models.CharField(max_length=120, blank=True)
oderdate = models.DateTimeField(auto_now_add=True)
is_active = models.BooleanField(default=True)
因子模型:
class ProductPriceFactor(models.Model):
factor_value = models.CharField(max_length=255)
name = models.CharField(max_length=255)
is_active = models.BooleanField(default=True)
orderdate 和 factor_values 来自不同的模型,因此 orderdate 来自 order 模型,factor_value 来自 ProductPriceFactor 模型。请帮我。
【问题讨论】:
标签: django python-3.x date django-templates