python - Global Variables in Django Admin Site -
this original question, not answered , thought id post again of strategies have tried, , little more specific.
i want create dynamic admin site, based on if field blank or not show field. have model has set number of fields, each individual entry not contain of fields in model , want exclude based on if field blank. project bridges, , put in practical terms have model has every bridge part in (this equivalent 100), each individual bridge (mapped each unique brkey) not have 100 bridge parts. , so, can prepopulate of fields have, admin site has 100 other fields, , not display fields not used on admin site specific bridge, fields differ pretty every bridge.
like said before, have unique bridge identifier(a unique 15 digit string), correlates each bridge, , of various different variables describe bridge.
i have set user go url unique bridgekey , create entry of bridge. (as testing on local machine) localhost/home/brkey , code in views.py corresponds url
is final route have take? new javascript , not want take route if have to. django use javascript in anyway syntactically different? if cannot find django documentation on incorporating javascript admin site.
a final option have exhausted use global variables. instead of having url creates entry in views.py, placed in admins.py, , had modeladmin class in there well, this.
admins.py
-set global variable
bridgekey_unique = " "
if can find way either pass unique bridge key modeladmin class, or figure out if said field blank because bridge doesnt have part, able achieve want without using javascript. have tried lot of variations of 2 of theses strategies no avail, have not tried javascript idea dont know javascript @ all.
sorry lengthy post, people said wasnt specific enough. appreciated.
i didn't read of - sorry, there's much. did notice comment expect access in modeladmin definition variable set in view. can't possibly work.
anything @ class level executed when module containing class first imported. when server process starts up, there no possible way done in view can have happened yet.
you never want have logic @ class level. need put in methods, called @ relevant time. in case, need use get_fields
method.
edit
looking further @ attempt @ get_fields method, can't see @ trying here. 'prestressed_concrete_deck'
literal string, , never none
, neither of conditions can ever true. , question parameters are, documentation method explains obj
object being edited.
Comments
Post a Comment