def _get_media(self): """ Construct Media as a dynamic property This is essential because we need to check RENDER_SELECT2_STATICS before returning our assets. for more information: https://docs.djangoproject.com/en/1.8/topics/forms/media/#media-as-a-dynamic-property """ if RENDER_SELECT2_STATICS: return forms.Media(js=get_select2_heavy_js_libs(), css={'screen': get_select2_css_libs()}) return forms.Media()
def _get_media(self): """ Construct Media as a dynamic property This is essential because we need to check RENDER_SELECT2_STATICS before returning our assets. for more information: https://docs.djangoproject.com/en/1.8/topics/forms/media/#media-as-a-dynamic-property """ if RENDER_SELECT2_STATICS: return forms.Media( js=get_select2_heavy_js_libs(), css={'screen': get_select2_css_libs()} ) return forms.Media()
class Media: if RENDER_SELECT2_STATICS: js = get_select2_heavy_js_libs() css = {'screen': get_select2_css_libs()}
def import_js(light=0): if light: js_files = get_select2_js_libs() else: js_files = get_select2_heavy_js_libs() return '\n'.join(script_tag(js_file) for js_file in js_files)