# Help Required: Django Admin display inlines dynamically with multiple select box

**URL:** <https://forum.djangoproject.com/t/help-required-django-admin-display-inlines-dynamically-with-multiple-select-box/3692>\
**Category:** Using Django\
**Created:** [July 31, 2020, 11:14am UTC](https://forum.djangoproject.com/t/help-required-django-admin-display-inlines-dynamically-with-multiple-select-box/3692 "2020-07-31T11:14:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![random-hostuser](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/random-hostuser/32/1790_2.png) [@random-hostuser](https://forum.djangoproject.com/u/random-hostuser)\
**Post date:** [July 31, 2020, 11:14am UTC](https://forum.djangoproject.com/t/help-required-django-admin-display-inlines-dynamically-with-multiple-select-box/3692/1 "2020-07-31T11:14:14Z")

</div>

Here is what my admin page looks like:

 ![Picture1](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/9/94fdb493504714b506091cee2a9d85c2752470fa.png)

As I add more models, I will have more foreign keys related to Selector and each instance of the selector model doesn’t need all the inlines. I would like to be able to select and choose which inlines to display for simplicity of the admin page. Does anyone have any suggestions on how I can simplify my page and have a dropdown multiple select box for dynamically displaying the inlines?

Here is my models.py file:

```
from django.db import models
class Selector(models.Model):
    lst = [
        ("Model1", "Model1"),
        ("Model2", "Model2"),
        ("Model3", "Model3"),
        ("Model4", "Model4"),
    ]
    choice = models.CharField("Choices", choices=lst, max_length=40)

class Model1(models.Model):
    select = models.ForeignKey(Selector, on_delete=models.CASCADE)
    param1 = models.IntegerField("Input 1")
    param2 = models.IntegerField("Input 2")
    param3 = models.IntegerField("Input 3")

class Model2(models.Model):
    select = models.ForeignKey(Selector, on_delete=models.CASCADE)
    param1 = models.IntegerField("Input 1")
    param2 = models.IntegerField("Input 2")
    param3 = models.IntegerField("Input 3")

class Model3(models.Model):
    select = models.ForeignKey(Selector, on_delete=models.CASCADE)
    param1 = models.IntegerField("Input 1")
    param2 = models.IntegerField("Input 2")
    param3 = models.IntegerField("Input 3")

class Model4(models.Model):
    select = models.ForeignKey(Selector, on_delete=models.CASCADE)
    param1 = models.IntegerField("Input 1")
    param2 = models.IntegerField("Input 2")
    param3 = models.IntegerField("Input 3")

```

Here is my admin.py file:

```
from django.contrib import admin
from .models import Model1, Model2, Model3, Model4, Selector

class Model1Admin(admin.TabularInline):
    model = Model1
    extra = 1

class Model2Admin(admin.TabularInline):
    model = Model2
    extra = 1

class Model3Admin(admin.TabularInline):
    model = Model3
    extra = 1

class Model4Admin(admin.TabularInline):
    model = Model4
    extra = 1

class SelectorAdmin(admin.ModelAdmin):
    model = Selector
    inlines = [Model1Admin, Model2Admin, Model3Admin, Model4Admin]

admin.site.register(Selector, SelectorAdmin)
```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [July 31, 2020, 11:48am UTC](https://forum.djangoproject.com/t/help-required-django-admin-display-inlines-dynamically-with-multiple-select-box/3692/2 "2020-07-31T11:48:08Z")

</div>

I would do this with a bit of JavaScript on the page.

Using jQuery, I’d register a `change` handler for the multi-select box. When the box detects a change, I’d iterate over all the entries, and either hide or show the corresponding element depending upon whether or not the entry was selected.

Ken
