我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用django.contrib.admin.TabularInline()。
def test_extends_tabular_inline(self): """ The class should extend django.contrib.admin.TabularInline """ self.assertTrue(issubclass(CsvGeneratorColumnInline, TabularInline))
def media(self): if not isinstance(self, InlineModelAdmin): context = {'field': self.ordering_field} else: if not self.fk_name: raise ImproperlyConfigured( '%r requires a `fk_name` -- we are too dumb/lazy to' ' determine it ourselves. Thanks!' % (self.__class__)) context = { 'field': self.ordering_field, 'prefix': get_default_formset_prefix( self.parent_model, self.model, self.fk_name), 'stacked': isinstance(self, admin.StackedInline), 'tabular': isinstance(self, admin.TabularInline), } return super(OrderableAdmin, self).media + forms.Media( css={'all': ( 'admin_ordering/admin_ordering.css', )}, js=[ 'admin_ordering/jquery-ui-1.11.4.custom.min.js', JS('admin_ordering/admin_ordering.js', { 'class': 'admin-ordering-context', 'data-context': json.dumps(context), }), ], )