django-suit icon indicating copy to clipboard operation
django-suit copied to clipboard

Add menu item using if/else condition???

Open asamuga opened this issue 7 years ago • 2 comments

How can I display/add a model to models tuple using inline if else

{'label': 'y', 'url': 'x' } if True else ____???

asamuga avatar Jun 26 '18 14:06 asamuga

You'd need to use Python code to construct the tuple from a list e.g.

>>> x = [{'label': 'y', 'url': 'x' }, {'label': 'a', 'url': 'b' }]
>>> a = True
>>> if a: 
...   x.append({'label': '1', 'url': '2' })
>>> y = tuple(x)  # do this after the construction is all finished

gamesbook avatar Jun 26 '18 17:06 gamesbook

https://github.com/darklow/django-suit/issues/693#issuecomment-400397974

wyattmcmahon avatar Dec 22 '19 01:12 wyattmcmahon