本文整理汇总了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)
)