On 3/05/2017 5:12 PM, Stephen J. Butler wrote:
You want to override get_inline_instances: https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_inline_instances

Many thanks Stephen - works nicely.

And thanks again to all you Django devs :)

M

On Wed, May 3, 2017 at 12:33 AM, Mike Dewhirst <mi...@dewhirst.com.au <mailto:mi...@dewhirst.com.au>> wrote:

    I want to adjust inlines based on a property of the object.

    class SubstanceAdmin(admin.ModelAdmin):

        class SolidInline(admin.StackedInline):
            pass
        class LiquidInline(admin.StackedInline):
            pass
        class GasInline(admin.StackedInline):
            pass

        inlines = get_inlines

        def get_inlines(self):
            obj = how_do_I_get_this(?)
            if obj.physical_state = None:
                return ((SolidInline), (LiquidInline), (GasInline))
            elif obj.physical_state = 1:
                return ((SolidInline), )
            elif obj.physical_state = 2:
                return ((LiquidInline), )
            elif obj.physical_state = 3:
                return ((GasInline), )

    Many thanks for a miracle :)

    Mike

-- You received this message because you are subscribed to the Google
    Groups "Django users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to django-users+unsubscr...@googlegroups.com
    <mailto:django-users%2bunsubscr...@googlegroups.com>.
    To post to this group, send email to django-users@googlegroups.com
    <mailto:django-users@googlegroups.com>.
    Visit this group at https://groups.google.com/group/django-users
    <https://groups.google.com/group/django-users>.
    To view this discussion on the web visit
    
https://groups.google.com/d/msgid/django-users/a138bd6c-46fb-98c7-ba28-69a5959e5fbc%40dewhirst.com.au
    
<https://groups.google.com/d/msgid/django-users/a138bd6c-46fb-98c7-ba28-69a5959e5fbc%40dewhirst.com.au>.
    For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.


--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD4ANxWWNxfDSCGUm8GFR_ijGL2WZAC%2Bwz3NCwpA%3DyHyALfWZQ%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAD4ANxWWNxfDSCGUm8GFR_ijGL2WZAC%2Bwz3NCwpA%3DyHyALfWZQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d59748f2-02c0-d331-52a1-75e0f37eb7a6%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to