python - A way to show/hide a field on Django -


i have list display in django admin

list_display = ('product', 'price', 'purchase_date', 'confirmed', 'get_po_number', 'notes') 

in models.py:

class purchaseorder(models.model):      notes = models.textfield( null=true, blank= true) 

this looks here:

[1]: http://i.imgur.com/zykmpof.png '

as can see 'notes' take lot of room, there way can view/hide field click of button?

instead of doing button, can resize field become smaller.

class purchaseadmin(admin.modeladmin): formfield_overrides = {     models.charfield: {'widget': textinput(attrs={'size':'20'})},     models.textfield: {'widget': textarea(attrs={'rows':4, 'cols':40})}, }  admin.site.register(purchaseorder, purchaseadmin) 

if want have button, can use custom inline class define fields:

class custominline(admin.tabularinline):     readonly_fields = [...'link',...]      # important part define "link" looks     def link(self, instance):        url = # link display note        return mark_safe(u'<a href="{u}">view note</a>".format(u=url)) 

and in custom admin class, use inline class instead:

class purchaseadmin(admin.modeladmin):     inlines = [custominline] 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -