本文整理匯總了Python中xadmin.filters.SEARCH_VAR屬性的典型用法代碼示例。如果您正苦於以下問題:Python filters.SEARCH_VAR屬性的具體用法?Python filters.SEARCH_VAR怎麽用?Python filters.SEARCH_VAR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類xadmin.filters
的用法示例。
在下文中一共展示了filters.SEARCH_VAR屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: block_top_navbar
# 需要導入模塊: from xadmin import filters [as 別名]
# 或者: from xadmin.filters import SEARCH_VAR [as 別名]
def block_top_navbar(self, context, nodes):
search_models = []
site_name = self.admin_site.name
if self.global_search_models == None:
models = self.admin_site._registry.keys()
else:
models = self.global_search_models
for model in models:
app_label = model._meta.app_label
if self.has_model_perm(model, "view"):
info = (app_label, model._meta.model_name)
if getattr(self.admin_site._registry[model], 'search_fields', None):
try:
search_models.append({
'title': _('Search %s') % capfirst(model._meta.verbose_name_plural),
'url': reverse('xadmin:%s_%s_changelist' % info, current_app=site_name),
'model': model
})
except NoReverseMatch:
pass
return nodes.append(loader.render_to_string('xadmin/blocks/comm.top.topnav.html', {'search_models': search_models, 'search_name': SEARCH_VAR}))
示例2: block_top_navbar
# 需要導入模塊: from xadmin import filters [as 別名]
# 或者: from xadmin.filters import SEARCH_VAR [as 別名]
def block_top_navbar(self, context, nodes):
search_models = []
site_name = self.admin_site.name
if self.global_search_models == None:
models = self.admin_site._registry.keys()
else:
models = self.global_search_models
for model in models:
app_label = model._meta.app_label
if self.has_model_perm(model, "view"):
info = (app_label, model._meta.model_name)
if getattr(self.admin_site._registry[model], 'search_fields', None):
try:
search_models.append({
'title': _('Search %s') % capfirst(model._meta.verbose_name_plural),
'url': reverse('xadmin:%s_%s_changelist' % info, current_app=site_name),
'model': model
})
except NoReverseMatch:
pass
nodes.append(loader.render_to_string('xadmin/blocks/comm.top.topnav.html', {'search_models': search_models, 'search_name': SEARCH_VAR}))
示例3: block_nav_form
# 需要導入模塊: from xadmin import filters [as 別名]
# 或者: from xadmin.filters import SEARCH_VAR [as 別名]
def block_nav_form(self, context, nodes):
if self.search_fields:
nodes.append(
loader.render_to_string(
'xadmin/blocks/model_list.nav_form.search_form.html',
{'search_var': SEARCH_VAR,
'remove_search_url': self.admin_view.get_query_string(remove=[SEARCH_VAR]),
'search_form_params': self.admin_view.get_form_params(remove=[SEARCH_VAR])},
context_instance=context))
示例4: block_nav_form
# 需要導入模塊: from xadmin import filters [as 別名]
# 或者: from xadmin.filters import SEARCH_VAR [as 別名]
def block_nav_form(self, context, nodes):
if self.search_fields:
context = get_context_dict(context or {}) # no error!
context.update({
'search_var': SEARCH_VAR,
'remove_search_url': self.admin_view.get_query_string(remove=[SEARCH_VAR]),
'search_form_params': self.admin_view.get_form_params(remove=[SEARCH_VAR])
})
nodes.append(
loader.render_to_string(
'xadmin/blocks/model_list.nav_form.search_form.html',
context=context)
)