Customer.objects.filter(customer_id__in=contact_list_senders)
contact_list_senders繰り返しクエリセットであるいくつかのcustomer_idsを含む繰り返しクエリセットである:ジャンゴobjects.filter(x__in = Y)yは
{sender_id1、sender_id2、sender_id1、sender_id2、sender_id1}
私はcontact_list_senders上記のコード
実際の出力とクエリセットからCustomerオブジェクトを検索してみてください。
{Customer1、Customer2}
所望の出力
{Customer1、Customer2、Customer1、Customer2、Customer1}
Iは、実際の出力ので理にかなって理解これらの連絡先と一致する顧客オブジェクトは2つだけです。あなたは希望の結果を得るために私を助けてもらえますか?
models.py:
class Customer(models.Model):
customer_id = models.CharField(max_length=244, blank=False, null=False)
first_name = models.CharField(max_length=244, blank=True, null=True)
last_name = models.CharField(max_length=244, blank=True, null=True)
email = models.CharField(max_length=244, blank=False, null=False)
enrollment_method = models.CharField(max_length=244, blank=True, null=False)
account_balance = models.DecimalField(default=0000.00, max_digits=6, decimal_places=2)
reserved_balance = models.DecimalField(default=0000.00, max_digits=6, decimal_places=2)
modified = models.DateTimeField(auto_now_add=True)
created = models.DateTimeField(auto_now_add=True)
あなたはlist_senderでループを実行し、その結果を1つにまとめる必要があるようです。 – viviwill