from django.contrib import admin
from member.models import (Member, Client, Contact, Address,
                           Referencing, Route, Client_avoid_component,
                           Client_avoid_ingredient, Option,
                           Client_option, Restriction)

admin.site.register(Member)
admin.site.register(Client)
admin.site.register(Route)
admin.site.register(Contact)
admin.site.register(Address)
admin.site.register(Referencing)
admin.site.register(Client_avoid_component)
admin.site.register(Client_avoid_ingredient)
admin.site.register(Option)
admin.site.register(Client_option)
admin.site.register(Restriction)

from django.contrib import admin
from member.models import (Member, Client, Contact, Address,
                           Referencing, Route, Client_avoid_component,
                           Client_avoid_ingredient, Option,
                           Client_option, Restriction)

from meal.models import Ingredient


class IngredientsToAvoidInline(admin.TabularInline):
    model = Client.ingredients_to_avoid.through


class ClientAdmin(admin.ModelAdmin):

    inlines = [
        IngredientsToAvoidInline
    ]


admin.site.register(Member)
admin.site.register(Client, ClientAdmin)
admin.site.register(Route)
admin.site.register(Contact)
admin.site.register(Address)
admin.site.register(Referencing)
admin.site.register(Client_avoid_component)
admin.site.register(Option)
admin.site.register(Client_option)
admin.site.register(Restriction)

Add ingredients to avoid as a TabularInline to Client
Add ingredients to avoid as a TabularInline to Client

Do not edit the ingredients to avoid directly, edit them through
a tabular form from the client form

  from django.contrib import admin
  from member.models import (Member, Client, Contact, Address,
                             Referencing, Route, Client_avoid_component,
                             Client_avoid_ingredient, Option,
                             Client_option, Restriction)
  
+ from meal.models import Ingredient
+ 
+ 
+ class IngredientsToAvoidInline(admin.TabularInline):
+     model = Client.ingredients_to_avoid.through
+ 
+ 
+ class ClientAdmin(admin.ModelAdmin):
+ 
+     inlines = [
+         IngredientsToAvoidInline
+     ]
+ 
+ 
  admin.site.register(Member)
- admin.site.register(Client)
+ admin.site.register(Client, ClientAdmin)
  admin.site.register(Route)
  admin.site.register(Contact)
  admin.site.register(Address)
  admin.site.register(Referencing)
  admin.site.register(Client_avoid_component)
- admin.site.register(Client_avoid_ingredient)
  admin.site.register(Option)
  admin.site.register(Client_option)
  admin.site.register(Restriction)
  
Add ingredients to avoid as a TabularInline to Client
## Code Before:
from django.contrib import admin
from member.models import (Member, Client, Contact, Address,
                           Referencing, Route, Client_avoid_component,
                           Client_avoid_ingredient, Option,
                           Client_option, Restriction)

admin.site.register(Member)
admin.site.register(Client)
admin.site.register(Route)
admin.site.register(Contact)
admin.site.register(Address)
admin.site.register(Referencing)
admin.site.register(Client_avoid_component)
admin.site.register(Client_avoid_ingredient)
admin.site.register(Option)
admin.site.register(Client_option)
admin.site.register(Restriction)

## Instruction:
Add ingredients to avoid as a TabularInline to Client
## Code After:
from django.contrib import admin
from member.models import (Member, Client, Contact, Address,
                           Referencing, Route, Client_avoid_component,
                           Client_avoid_ingredient, Option,
                           Client_option, Restriction)

from meal.models import Ingredient


class IngredientsToAvoidInline(admin.TabularInline):
    model = Client.ingredients_to_avoid.through


class ClientAdmin(admin.ModelAdmin):

    inlines = [
        IngredientsToAvoidInline
    ]


admin.site.register(Member)
admin.site.register(Client, ClientAdmin)
admin.site.register(Route)
admin.site.register(Contact)
admin.site.register(Address)
admin.site.register(Referencing)
admin.site.register(Client_avoid_component)
admin.site.register(Option)
admin.site.register(Client_option)
admin.site.register(Restriction)
