# Smart collections in django

**URL:** <https://community.forestadmin.com/t/smart-collections-in-django/6268>\
**Category:** Help me!\
**Tags:** smart-collection\
**Created:** [May 8, 2023, 11:19am UTC](https://community.forestadmin.com/t/smart-collections-in-django/6268 "2023-05-08T11:19:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohamed\_Ezzaalyouy](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/mohamed_ezzaalyouy/32/6039_2.png) [@Mohamed\_Ezzaalyouy](https://community.forestadmin.com/u/Mohamed_Ezzaalyouy)\
**Post date:** [May 8, 2023, 11:19am UTC](https://community.forestadmin.com/t/smart-collections-in-django/6268/1 "2023-05-08T11:19:05Z")

</div>

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

> **[Smart Collections | Developer Guide](https://docs.forestadmin.com/documentation/reference-guide/smart-collections)**

I want to add a field: **phone** in my collection **CustomerStat** :

```javascript
           {
                'field': 'phone',
                'type': 'Number'
            }

```

**phone is field in table ‘Model’ Address**

**Model Customer:**

```javascript
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:**

```javascript
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 😊

---

<div class="post-metadata">

**Author:** ![Alban\_Bertolini](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/alban_bertolini/32/1077_2.png) [@Alban\_Bertolini](https://community.forestadmin.com/u/Alban_Bertolini)\
**Post date:** [May 9, 2023, 11:03am UTC](https://community.forestadmin.com/t/smart-collections-in-django/6268/2 "2023-05-09T11:03:01Z")

</div>

Hello,  
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 ?

---

<div class="post-metadata">

**Author:** ![Mohamed\_Ezzaalyouy](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/mohamed_ezzaalyouy/32/6039_2.png) [@Mohamed\_Ezzaalyouy](https://community.forestadmin.com/u/Mohamed_Ezzaalyouy)\
**Post date:** [May 9, 2023, 11:14am UTC](https://community.forestadmin.com/t/smart-collections-in-django/6268/3 "2023-05-09T11:14:37Z")

</div>

Hi @Alban_Bertolini ,

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

 ![forest](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/3/3c336ae48db2cf286ca097c27b771d34b753743a.png)

---

<div class="post-metadata">

**Author:** ![Alban\_Bertolini](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/alban_bertolini/32/1077_2.png) [@Alban\_Bertolini](https://community.forestadmin.com/u/Alban_Bertolini)\
**Post date:** [May 9, 2023, 1:00pm UTC](https://community.forestadmin.com/t/smart-collections-in-django/6268/4 "2023-05-09T13:00:36Z")

</div>

To import the `phone` field, you can use this [smart field tutorial](https://docs.forestadmin.com/documentation/reference-guide/smart-fields).
