**models.py** コードclass OrderItem(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE) user_name = models.CharField(max_length=50,null=True,blank=True) user_email = models.CharField(max_length=50,null=True,blank=True) ordered = models.BooleanField(default=False) item = models.ForeignKey(Item,on_delete=models.CASCADE) quantity = models.IntegerField(default=1) order_day = models.DateField('注文日',default=timezone.now) store_name = models.CharField('店舗名',max_length=30,blank=True,null=True) def get_total_item_price(self):**呼び出せる** return int(self.quantity * self.item.price) def get_end_total(self):**これが呼び出せない** total = 0 for items in self.item: total += items.get_total_item_price() return total def __str__(self): return f'{self.item.title}:{self.quantity}' **views.py** class FindView(View): def get(self,request, *args, **kwargs): today = timezone.now() keyword = request.GET.get('keyword') order = OrderItem.objects.filter(store_name=keyword,order_day=today) context = { 'order' :order, } return render(request,'order/order_data.html',context) **templaet HTML** <v-simple-table class="mt-2"> <template v-slot:default> <thead class="pink lighten-5 font-weight-bold"> <tr> <th>日 付</th> <th>お名前</th> <th>店舗名</th> <th>商品名</th> <th>数 量</th> <th>小 計</th> </tr> </thead> <tbody> <tr>{% for order_data in order %} <td>{{ order_data.order_day }}</td> <td>{{ order_data.user }}</td> <td>{{ order_data.store_name }}</td> <td>{{ order_data.item.item.title }}</td> <td class="text-center">{{ order_data.quantity }}</td> <td class="text-right">{{ order_data.get_total_item_price|intcomma }}</td> </tr> {% endfor %} </tbody> <tr> <td></td> <td></td> <td></td> <td col="3"class="text-right"><h3>合計金額{{ order.get_end_total|intcomma }}円</h3> </td>**ここが表示できない** </tr> </template> </v-simple-table>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。