1

私はクーポンを持っていない結果からそれらの店舗を削除したい.私のmodels.pyは次のとおりです..これは店舗モデルであり、対応するクーポンデータがないすべての店舗を削除したい

class stores(models.Model):
    """ This is the store model """
    storeName = models.CharField(max_length=15)                                          # Store Name
    storeDescription = models.TextField()                                                # Store Description
    storeURL = models.URLField()                                                         # Store URL
    storePopularityNumber = models.IntegerField(choices=PRIORITY_CHOICES,default=3)      # Store Popularity Number  
    storeImage = models.ImageField(upload_to="images")                                   # Store Image 
    storeSlug = models.CharField(max_length=400)                                         # This is the text you see in the URL
    createdAt = models.DateTimeField(auto_now_add=True)                                  # Time at which store is created
    updatedAt = models.DateTimeField(auto_now=True)                                      # Time at which store is updated
    storeTags = models.ManyToManyField(tags)                                             # All the tags associated with the store

クーポンモデルは次のとおりです。

class coupons(models.Model):
    """ This is the coupon model """
    couponTitle = models.CharField(max_length=100,default="")
    couponCode = models.CharField(max_length=30)
    couponValue = models.CharField(max_length=50)                             # Coupon value in RS.
    couponDescription = models.TextField()                                    # Coupon Description
    couponURL = models.URLField(default='http://www.foo.com')                 # Coupon click URL
    couponStore = models.ForeignKey(stores,on_delete=models.PROTECT)          # Key of coupon to store
    couponTags = models.ManyToManyField(tags)                                 # Tag names associated to coupon
    success = models.TextField(default=' ')                                   # Count of the number of times people have made it work
    failures =  models.TextField(default=' ')                                 # Count of the number of times this has failed
    lastTested = models.DateTimeField(auto_now=True)                          # When was the coupon last tested
    updatedAt = models.DateTimeField(auto_now=True)
    createdAt = models.DateTimeField(auto_now_add=True)
    addedOn = models.DateTimeField()
    active =  models.BooleanField(default=True)

だれか助けてください...関連するクーポンデータがないすべてのストアを除外する必要があります....

4

1 に答える 1