Django admin with multiple inlines of the same model
I'm having a problem with prefixes of StackedInlines in admin interface. I'll try to post all the necesary code.

**models.py (brief)**

    ##### Base classes

    class BaseItem(models.Model):
        pass

    class BaseProvider(PolymorphicModel):
       items = models.ManyToManyField(BaseItem, through="ItemProvided")

    class ItemProvided(models.Model):
        item = models.ForeignKey(BaseItem)
        provider = models.ForeignKey(BaseProvider)
        price = models.IntegerField()

    ##### Implementing ones

    class Hotel(BaseProvider):
        pass

    class Service(BaseItem):
        pass

    class Service(BaseItem):
        pass

This hierachy reads as follows: a hotel is a provider which can provide either rooms or services.

**admin.py (brief)**

    #### Creating admin.StackedInline for Rooms

    class RoomInlineFormSet(BaseInlineFormSet):
        def __init__(self, *args, **kwargs):
            kwargs.update({'prefix':'room'})
            super(RoomInlineFormSet, self).__init__(*args, **kwargs)

    class HotelRoomInline(admin.StackedInline):
        # This class also filters 'item' choiceField in order to have only ItemProvideds which are rooms
        model = ItemProvided
        formset = RoomInlineFormSet


    #### Creating admin.StackedInline for Services

    class ServiceInlineFormSet(BaseInlineFormSet):
        def __init__(self, *args, **kwargs):
            kwargs.update({'prefix':'service'})
            super(ServiceInlineFormSet, self).__init__(*args, **kwargs)

    class HotelServiceInline(admin.StackedInline):
        # This class also filters 'item' choiceField in order to have only ItemProvideds which are services
        model = ItemProvided
        formset = ServiceInlineFormSet


    #### Adding inlines to HotelAdmin and model to admin interface

    class HotelAdmin(admin.ModelAdmin):
        inlines = [
               HotelRoomInline,
               HotelServiceInline,
               ]

    admin.site.register(Hotel, HotelAdmin)


With this code I managed to get two separated StackedInlines in admin interface for Hotel model, each of them allowing to select only the proper subset of itemprovideds. Great.

**The problem:** if a have one itemprovided created, in the room's StackedInline, for example; both StackedInlines are populated with the data... prefixes are not well managed...

 - Is there anything wrong and obvious in the code I'm not seeing?
 - Is there any other good option two obtain the pretended layout in admin interface?

Django admin with multiple inlines of the same model
===

I'm having a problem with prefixes of StackedInlines in admin interface. I'll try to post all the necesary code.

**models.py (brief)**

    ##### Base classes

    class BaseItem(models.Model):
        pass

    class BaseProvider(PolymorphicModel):
       items = models.ManyToManyField(BaseItem, through="ItemProvided")

    class ItemProvided(models.Model):
        item = models.ForeignKey(BaseItem)
        provider = models.ForeignKey(BaseProvider)
        price = models.IntegerField()

    ##### Implementing ones

    class Hotel(BaseProvider):
        pass

    class Service(BaseItem):
        pass

    class Service(BaseItem):
        pass

This hierachy reads as follows: a hotel is a provider which can provide either rooms or services.

**admin.py (brief)**

    #### Creating admin.StackedInline for Rooms

    class RoomInlineFormSet(BaseInlineFormSet):
        def __init__(self, *args, **kwargs):
            kwargs.update({'prefix':'room'})
            super(RoomInlineFormSet, self).__init__(*args, **kwargs)

    class HotelRoomInline(admin.StackedInline):
        # This class also filters 'item' choiceField in order to have only ItemProvideds which are rooms
        model = ItemProvided
        formset = RoomInlineFormSet


    #### Creating admin.StackedInline for Services

    class ServiceInlineFormSet(BaseInlineFormSet):
        def __init__(self, *args, **kwargs):
            kwargs.update({'prefix':'service'})
            super(ServiceInlineFormSet, self).__init__(*args, **kwargs)

    class HotelServiceInline(admin.StackedInline):
        # This class also filters 'item' choiceField in order to have only ItemProvideds which are services
        model = ItemProvided
        formset = ServiceInlineFormSet


    #### Adding inlines to HotelAdmin and model to admin interface

    class HotelAdmin(admin.ModelAdmin):
        inlines = [
               HotelRoomInline,
               HotelServiceInline,
               ]

    admin.site.register(Hotel, HotelAdmin)


With this code I managed to get two separated StackedInlines in admin interface for Hotel model, each of them allowing to select only the proper subset of itemprovideds. Great.

**The problem:** if a have one itemprovided created, in the room's StackedInline, for example; both StackedInlines are populated with the data... prefixes are not well managed...

 - Is there anything wrong and obvious in the code I'm not seeing?
 - Is there any other good option two obtain the pretended layout in admin interface?
