hello i hope you are fine,
Feature(s) impacted
smart collections in django
Context
- Project name: ftft-saleor
- Environment name: ftft-saleor / Django
- Database type: Postgres
How can me create Smart Collection in django through two tables in database ?
for example here in the Docs example:
I want to add a field: phone in my collection CustomerStat:
{
'field': 'phone',
'type': 'Number'
}
phone is field in table ‘Model’ Address
Model Customer:
class Customer(models.Model):
addresses = models.ManyToManyField(
Address, blank=True, related_name="user_addresses"
)
orders = models.ManyToManyField(Order)
product = models.ManyToManyField(Products)
name = models.CharField(max_length=255)
email = models.EmailField(unique=True)
created_at = models.DateTimeField(auto_now_add=True )
def __str__(self) -> str:
return self.name
Model Address:
class Address(models.Model):
phone = models.CharField(max_length= 20,blank=True, default="", db_index=True)
street_address_1 = models.CharField(max_length=256, blank=True)
street_address_2 = models.CharField(max_length=256, blank=True)
city = models.CharField(max_length=256, blank=True)
phone = models.CharField(max_length= 20,blank=True, default="", db_index=True)
Thank you for your support