Smart collections in django

hello i hope you are fine,

Feature(s) impacted

smart collections in django


  • 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:

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 :blush:

To understand your needs, you want to create a smart collection CustomerStat and add a phone attribute that refers the phone attribute in the address collection ?

Hi @Alban_Bertolini ,

yes, i want to add phone attribute to smart collection CustomerStat

To import the phone field, you can use this smart field tutorial.

1 Like