2
0

indexview.rst 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. ============================================
  2. Customising ``IndexView`` - the listing view
  3. ============================================
  4. For the sake of consistency, this section of the docs will refer to the listing
  5. view as ``IndexView``, because that is the view class that does all the heavy
  6. lifting.
  7. You can use the following attributes and methods on the ``ModelAdmin`` class to
  8. alter how your model data is treated and represented by the ``IndexView``.
  9. .. contents::
  10. :local:
  11. :depth: 1
  12. .. _modeladmin_list_display:
  13. ---------------------------
  14. ``ModelAdmin.list_display``
  15. ---------------------------
  16. **Expected value**: A list or tuple, where each item is the name of a field or
  17. single-argument callable on your model, or a similarly simple method defined
  18. on the ``ModelAdmin`` class itself.
  19. Default value: ``('__str__',)``
  20. Set ``list_display`` to control which fields are displayed in the ``IndexView``
  21. for your model.
  22. You have three possible values that can be used in ``list_display``:
  23. - A field of the model. For example:
  24. .. code-block:: python
  25. from wagtail.contrib.modeladmin.options import ModelAdmin
  26. from .models import Person
  27. class PersonAdmin(ModelAdmin):
  28. model = Person
  29. list_display = ('first_name', 'last_name')
  30. - The name of a custom method on your ``ModelAdmin`` class, that accepts a
  31. single parameter for the model instance. For example:
  32. .. code-block:: python
  33. from wagtail.contrib.modeladmin.options import ModelAdmin
  34. from .models import Person
  35. class PersonAdmin(ModelAdmin):
  36. model = Person
  37. list_display = ('upper_case_name',)
  38. def upper_case_name(self, obj):
  39. return ("%s %s" % (obj.first_name, obj.last_name)).upper()
  40. upper_case_name.short_description = 'Name'
  41. - The name of a method on your ``Model`` class that accepts only ``self`` as
  42. an argument. For example:
  43. .. code-block:: python
  44. from django.db import models
  45. from wagtail.contrib.modeladmin.options import ModelAdmin
  46. class Person(models.Model):
  47. name = models.CharField(max_length=50)
  48. birthday = models.DateField()
  49. def decade_born_in(self):
  50. return self.birthday.strftime('%Y')[:3] + "0's"
  51. decade_born_in.short_description = 'Birth decade'
  52. class PersonAdmin(ModelAdmin):
  53. model = Person
  54. list_display = ('name', 'decade_born_in')
  55. A few special cases to note about ``list_display``:
  56. - If the field is a ``ForeignKey``, Django will display the output of
  57. ``__str__()`` of the related object.
  58. - If the string provided is a method of the model or ``ModelAdmin`` class,
  59. Django will HTML-escape the output by default. To escape user input and
  60. allow your own unescaped tags, use ``format_html()``. For example:
  61. .. code-block:: python
  62. from django.db import models
  63. from django.utils.html import format_html
  64. from wagtail.contrib.modeladmin.options import ModelAdmin
  65. class Person(models.Model):
  66. first_name = models.CharField(max_length=50)
  67. last_name = models.CharField(max_length=50)
  68. color_code = models.CharField(max_length=6)
  69. def colored_name(self):
  70. return format_html(
  71. '<span style="color: #{};">{} {}</span>',
  72. self.color_code,
  73. self.first_name,
  74. self.last_name,
  75. )
  76. class PersonAdmin(ModelAdmin):
  77. model = Person
  78. list_display = ('first_name', 'last_name', 'colored_name')
  79. - If the value of a field is ``None``, an empty string, or an iterable
  80. without elements, Wagtail will display a dash (-) for that column. You can
  81. override this by setting ``empty_value_display`` on your ``ModelAdmin``
  82. class. For example:
  83. .. code-block:: python
  84. from wagtail.contrib.modeladmin.options import ModelAdmin
  85. class PersonAdmin(ModelAdmin):
  86. empty_value_display = 'N/A'
  87. ...
  88. Or, if you'd like to change the value used depending on the field, you can
  89. override ``ModelAdmin``'s ``get_empty_value_display()`` method, like so:
  90. .. code-block:: python
  91. from django.db import models
  92. from wagtail.contrib.modeladmin.options import ModelAdmin
  93. class Person(models.Model):
  94. name = models.CharField(max_length=100)
  95. nickname = models.CharField(blank=True, max_length=100)
  96. likes_cat_gifs = models.NullBooleanField()
  97. class PersonAdmin(ModelAdmin):
  98. model = Person
  99. list_display = ('name', 'nickname', 'likes_cat_gifs')
  100. def get_empty_value_display(self, field_name=None):
  101. if field_name == 'nickname':
  102. return 'None given'
  103. if field_name == 'likes_cat_gifs':
  104. return 'Unanswered'
  105. return super().get_empty_value_display(field_name)
  106. The ``__str__()`` method is just as valid
  107. in ``list_display`` as any other model method, so it’s perfectly OK to do
  108. this:
  109. .. code-block:: python
  110. list_display = ('__str__', 'some_other_field')
  111. By default, the ability to sort results by an item in ``list_display`` is
  112. only offered when it's a field that has an actual database value (because
  113. sorting is done at the database level). However, if the output of the
  114. method is representative of a database field, you can indicate this fact by
  115. setting the ``admin_order_field`` attribute on that method, like so:
  116. .. code-block:: python
  117. from django.db import models
  118. from django.utils.html import format_html
  119. from wagtail.contrib.modeladmin.options import ModelAdmin
  120. class Person(models.Model):
  121. first_name = models.CharField(max_length=50)
  122. last_name = models.CharField(max_length=50)
  123. color_code = models.CharField(max_length=6)
  124. def colored_first_name(self):
  125. return format_html(
  126. '<span style="color: #{};">{}</span>',
  127. self.color_code,
  128. self.first_name,
  129. )
  130. colored_first_name.admin_order_field = 'first_name'
  131. class PersonAdmin(ModelAdmin):
  132. model = Person
  133. list_display = ('colored_first_name', 'last_name')
  134. The above will tell Wagtail to order by the ``first_name`` field when
  135. trying to sort by ``colored_first_name`` in the index view.
  136. To indicate descending order with ``admin_order_field`` you can use a
  137. hyphen prefix on the field name. Using the above example, this would look
  138. like:
  139. .. code-block:: python
  140. colored_first_name.admin_order_field = '-first_name'
  141. ``admin_order_field`` supports query lookups to sort by values on related
  142. models, too. This example includes an “author first name” column in the
  143. list display and allows sorting it by first name:
  144. .. code-block:: python
  145. from django.db import models
  146. class Blog(models.Model):
  147. title = models.CharField(max_length=255)
  148. author = models.ForeignKey(Person, on_delete=models.CASCADE)
  149. def author_first_name(self, obj):
  150. return obj.author.first_name
  151. author_first_name.admin_order_field = 'author__first_name'
  152. - Elements of ``list_display`` can also be properties. Please note however,
  153. that due to the way properties work in Python, setting
  154. ``short_description`` on a property is only possible when using the
  155. ``property()`` function and **not** with the ``@property`` decorator.
  156. For example:
  157. .. code-block:: python
  158. from django.db import models
  159. from wagtail.contrib.modeladmin.options import ModelAdmin
  160. class Person(models.Model):
  161. first_name = models.CharField(max_length=50)
  162. last_name = models.CharField(max_length=50)
  163. def full_name_property(self):
  164. return self.first_name + ' ' + self.last_name
  165. full_name_property.short_description = "Full name of the person"
  166. full_name = property(full_name_property)
  167. class PersonAdmin(ModelAdmin):
  168. list_display = ('full_name',)
  169. .. _modeladmin_list_export:
  170. ---------------------------
  171. ``ModelAdmin.list_export``
  172. ---------------------------
  173. **Expected value**: A list or tuple, where each item is the name of a field or
  174. single-argument callable on your model, or a similarly simple method defined
  175. on the ``ModelAdmin`` class itself.
  176. Set ``list_export`` to set the fields you wish to be exported as columns when
  177. downloading a spreadsheet version of your index_view
  178. .. code-block:: python
  179. class PersonAdmin(ModelAdmin):
  180. list_export = ('is_staff', 'company')
  181. .. _modeladmin_list_filter:
  182. ---------------------------
  183. ``ModelAdmin.list_filter``
  184. ---------------------------
  185. **Expected value**: A list or tuple, where each item is the name of model field
  186. of type ``BooleanField``, ``CharField``, ``DateField``, ``DateTimeField``,
  187. ``IntegerField`` or ``ForeignKey``.
  188. Set ``list_filter`` to activate filters in the right sidebar of the list page
  189. for your model. For example:
  190. .. code-block:: python
  191. class PersonAdmin(ModelAdmin):
  192. list_filter = ('is_staff', 'company')
  193. .. _modeladmin_export_filename:
  194. ------------------------------
  195. ``ModelAdmin.export_filename``
  196. ------------------------------
  197. **Expected value**: A string specifying the filename of an exported spreadsheet,
  198. without file extensions.
  199. .. code-block:: python
  200. class PersonAdmin(ModelAdmin):
  201. export_filename = 'people_spreadsheet'
  202. .. _modeladmin_search_fields:
  203. ----------------------------
  204. ``ModelAdmin.search_fields``
  205. ----------------------------
  206. **Expected value**: A list or tuple, where each item is the name of a model
  207. field of type ``CharField``, ``TextField``, ``RichTextField`` or
  208. ``StreamField``.
  209. Set ``search_fields`` to enable a search box at the top of the index page
  210. for your model. You should add names of any fields on the model that should
  211. be searched whenever somebody submits a search query using the search box.
  212. Searching is handled via Django's QuerySet API by default,
  213. see `ModelAdmin.search_handler_class`_ about changing this behaviour.
  214. This means by default it will work for all models, whatever search backend
  215. your project is using, and without any additional setup or configuration.
  216. .. _modeladmin_search_handler_class:
  217. -----------------------------------
  218. ``ModelAdmin.search_handler_class``
  219. -----------------------------------
  220. **Expected value**: A subclass of
  221. ``wagtail.contrib.modeladmin.helpers.search.BaseSearchHandler``
  222. The default value is ``DjangoORMSearchHandler``, which uses the Django ORM to
  223. perform lookups on the fields specified by ``search_fields``.
  224. If you would prefer to use the built-in Wagtail search backend to search your
  225. models, you can use the ``WagtailBackendSearchHandler`` class instead. For
  226. example:
  227. .. code-block:: python
  228. from wagtail.contrib.modeladmin.helpers import WagtailBackendSearchHandler
  229. from .models import Person
  230. class PersonAdmin(ModelAdmin):
  231. model = Person
  232. search_handler_class = WagtailBackendSearchHandler
  233. Extra considerations when using ``WagtailBackendSearchHandler``
  234. ===============================================================
  235. ``ModelAdmin.search_fields`` is used differently
  236. ------------------------------------------------
  237. The value of ``search_fields`` is passed to the underlying search backend to
  238. limit the fields used when matching. Each item in the list must be indexed
  239. on your model using :ref:`wagtailsearch_index_searchfield`.
  240. To allow matching on **any** indexed field, set the ``search_fields`` attribute
  241. on your ``ModelAdmin`` class to ``None``, or remove it completely.
  242. Indexing extra fields using ``index.FilterField``
  243. -------------------------------------------------
  244. The underlying search backend must be able to interpret all of the fields and
  245. relationships used in the queryset created by ``IndexView``, including those
  246. used in ``prefetch()`` or ``select_related()`` queryset methods, or used in
  247. ``list_display``, ``list_filter`` or ``ordering``.
  248. Be sure to test things thoroughly in a development environment (ideally
  249. using the same search backend as you use in production). Wagtail will raise
  250. an ``IndexError`` if the backend encounters something it does not understand,
  251. and will tell you what you need to change.
  252. .. _modeladmin_extra_search_kwargs:
  253. ----------------------------------
  254. ``ModelAdmin.extra_search_kwargs``
  255. ----------------------------------
  256. **Expected value**: A dictionary of keyword arguments that will be passed on to the ``search()`` method of
  257. ``search_handler_class``.
  258. For example, to override the ``WagtailBackendSearchHandler`` default operator you could do the following:
  259. .. code-block:: python
  260. from wagtail.contrib.modeladmin.helpers import WagtailBackendSearchHandler
  261. from wagtail.search.utils import OR
  262. from .models import IndexedModel
  263. class DemoAdmin(ModelAdmin):
  264. model = IndexedModel
  265. search_handler_class = WagtailBackendSearchHandler
  266. extra_search_kwargs = {'operator': OR}
  267. .. _modeladmin_ordering:
  268. ---------------------------
  269. ``ModelAdmin.ordering``
  270. ---------------------------
  271. **Expected value**: A list or tuple in the same format as a model’s
  272. :attr:`~django.db.models.Options.ordering` parameter.
  273. Set ``ordering`` to specify the default ordering of objects when listed by
  274. IndexView. If not provided, the model’s default ordering will be respected.
  275. If you need to specify a dynamic order (for example, depending on user or
  276. language) you can override the ``get_ordering()`` method instead.
  277. .. _modeladmin_list_per_page:
  278. ----------------------------
  279. ``ModelAdmin.list_per_page``
  280. ----------------------------
  281. **Expected value**: A positive integer
  282. Set ``list_per_page`` to control how many items appear on each paginated page
  283. of the index view. By default, this is set to ``100``.
  284. .. _modeladmin_get_queryset:
  285. -----------------------------
  286. ``ModelAdmin.get_queryset()``
  287. -----------------------------
  288. **Must return**: A QuerySet
  289. The ``get_queryset`` method returns the 'base' QuerySet for your model, to
  290. which any filters and search queries are applied. By default, the ``all()``
  291. method of your model's default manager is used. But, if for any reason you
  292. only want a certain sub-set of objects to appear in the IndexView listing,
  293. overriding the ``get_queryset`` method on your ``ModelAdmin`` class can help
  294. you with that. The method takes an ``HttpRequest`` object as a parameter, so
  295. limiting objects by the current logged-in user is possible.
  296. For example:
  297. .. code-block:: python
  298. from django.db import models
  299. from wagtail.contrib.modeladmin.options import ModelAdmin
  300. class Person(models.Model):
  301. first_name = models.CharField(max_length=50)
  302. last_name = models.CharField(max_length=50)
  303. managed_by = models.ForeignKey('auth.User', on_delete=models.CASCADE)
  304. class PersonAdmin(ModelAdmin):
  305. model = Person
  306. list_display = ('first_name', 'last_name')
  307. def get_queryset(self, request):
  308. qs = super().get_queryset(request)
  309. # Only show people managed by the current user
  310. return qs.filter(managed_by=request.user)
  311. .. _modeladmin_get_extra_attrs_for_row:
  312. ----------------------------------------------------
  313. ``ModelAdmin.get_extra_attrs_for_row()``
  314. ----------------------------------------------------
  315. **Must return**: A dictionary
  316. The ``get_extra_attrs_for_row`` method allows you to add html attributes to
  317. the opening ``<tr>`` tag for each result, in addition to the ``data-object_pk`` and
  318. ``class`` attributes already added by the ``result_row_display`` template tag.
  319. If you want to add additional CSS classes, simply provide those class names
  320. as a string value using the ``'class'`` key, and the ``odd``/``even`` will be appended
  321. to your custom class names when rendering.
  322. For example, if you wanted to add some additional class names based on field
  323. values, you could do something like:
  324. .. code-block:: python
  325. from decimal import Decimal
  326. from django.db import models
  327. from wagtail.contrib.modeladmin.options import ModelAdmin
  328. class BankAccount(models.Model):
  329. name = models.CharField(max_length=50)
  330. account_number = models.CharField(max_length=50)
  331. balance = models.DecimalField(max_digits=5, num_places=2)
  332. class BankAccountAdmin(ModelAdmin):
  333. list_display = ('name', 'account_number', 'balance')
  334. def get_extra_attrs_for_row(self, obj, context):
  335. if obj.balance < Decimal('0.00'):
  336. classname = 'balance-negative'
  337. else:
  338. classname = 'balance-positive'
  339. return {
  340. 'class': classname,
  341. }
  342. .. _modeladmin_get_extra_class_names_for_field_col:
  343. ----------------------------------------------------
  344. ``ModelAdmin.get_extra_class_names_for_field_col()``
  345. ----------------------------------------------------
  346. **Must return**: A list
  347. The ``get_extra_class_names_for_field_col`` method allows you to add additional
  348. CSS class names to any of the columns defined by ``list_display`` for your
  349. model. The method takes two parameters:
  350. - ``obj``: the object being represented by the current row
  351. - ``field_name``: the item from ``list_display`` being represented by the
  352. current column
  353. For example, if you'd like to apply some conditional formatting to a cell
  354. depending on the row's value, you could do something like:
  355. .. code-block:: python
  356. from decimal import Decimal
  357. from django.db import models
  358. from wagtail.contrib.modeladmin.options import ModelAdmin
  359. class BankAccount(models.Model):
  360. name = models.CharField(max_length=50)
  361. account_number = models.CharField(max_length=50)
  362. balance = models.DecimalField(max_digits=5, num_places=2)
  363. class BankAccountAdmin(ModelAdmin):
  364. list_display = ('name', 'account_number', 'balance')
  365. def get_extra_class_names_for_field_col(self, obj, field_name):
  366. if field_name == 'balance':
  367. if obj.balance <= Decimal('-100.00'):
  368. return ['brand-danger']
  369. elif obj.balance <= Decimal('-0.00'):
  370. return ['brand-warning']
  371. elif obj.balance <= Decimal('50.00'):
  372. return ['brand-info']
  373. else:
  374. return ['brand-success']
  375. return []
  376. .. _modeladmin_get_extra_attrs_for_field_col:
  377. ----------------------------------------------------
  378. ``ModelAdmin.get_extra_attrs_for_field_col()``
  379. ----------------------------------------------------
  380. **Must return**: A dictionary
  381. The ``get_extra_attrs_for_field_col`` method allows you to add additional HTML
  382. attributes to any of the columns defined in ``list_display``. Like the
  383. ``get_extra_class_names_for_field_col`` method above, this method takes two
  384. parameters:
  385. - ``obj``: the object being represented by the current row
  386. - ``field_name``: the item from ``list_display`` being represented by the
  387. current column
  388. For example, you might like to add some tooltip text to a certain column, to
  389. help give the value more context:
  390. .. code-block:: python
  391. from django.db import models
  392. from wagtail.contrib.modeladmin.options import ModelAdmin
  393. class Person(models.Model):
  394. name = models.CharField(max_length=100)
  395. likes_cat_gifs = models.NullBooleanField()
  396. class PersonAdmin(ModelAdmin):
  397. model = Person
  398. list_display = ('name', 'likes_cat_gifs')
  399. def get_extra_attrs_for_field_col(self, obj, field_name=None):
  400. attrs = super().get_extra_attrs_for_field_col(obj, field_name)
  401. if field_name == 'likes_cat_gifs' and obj.likes_cat_gifs is None:
  402. attrs.update({
  403. 'title': (
  404. 'The person was shown several cat gifs, but failed to '
  405. 'indicate a preference.'
  406. ),
  407. })
  408. return attrs
  409. Or you might like to add one or more data attributes to help implement some
  410. kind of interactivity using JavaScript:
  411. .. code-block:: python
  412. from django.db import models
  413. from wagtail.contrib.modeladmin.options import ModelAdmin
  414. class Event(models.Model):
  415. title = models.CharField(max_length=255)
  416. start_date = models.DateField()
  417. end_date = models.DateField()
  418. start_time = models.TimeField()
  419. end_time = models.TimeField()
  420. class EventAdmin(ModelAdmin):
  421. model = Event
  422. list_display = ('title', 'start_date', 'end_date')
  423. def get_extra_attrs_for_field_col(self, obj, field_name=None):
  424. attrs = super().get_extra_attrs_for_field_col(obj, field_name)
  425. if field_name == 'start_date':
  426. # Add the start time as data to the 'start_date' cell
  427. attrs.update({ 'data-time': obj.start_time.strftime('%H:%M') })
  428. elif field_name == 'end_date':
  429. # Add the end time as data to the 'end_date' cell
  430. attrs.update({ 'data-time': obj.end_time.strftime('%H:%M') })
  431. return attrs
  432. .. _modeladmin_thumbnailmixin:
  433. ----------------------------------------------------
  434. ``wagtail.contrib.modeladmin.mixins.ThumbnailMixin``
  435. ----------------------------------------------------
  436. If you're using ``wagtailimages.Image`` to define an image for each item in
  437. your model, ``ThumbnailMixin`` can help you add thumbnail versions of that
  438. image to each row in ``IndexView``. To use it, simply extend ``ThumbnailMixin``
  439. as well as ``ModelAdmin`` when defining your ``ModelAdmin`` class, and
  440. change a few attributes to change the thumbnail to your liking, like so:
  441. .. code-block:: python
  442. from django.db import models
  443. from wagtail.contrib.modeladmin.mixins import ThumbnailMixin
  444. from wagtail.contrib.modeladmin.options import ModelAdmin
  445. class Person(models.Model):
  446. name = models.CharField(max_length=255)
  447. avatar = models.ForeignKey('wagtailimages.Image', on_delete=models.SET_NULL, null=True)
  448. likes_cat_gifs = models.NullBooleanField()
  449. class PersonAdmin(ThumbnailMixin, ModelAdmin):
  450. # Add 'admin_thumb' to list_display, where you want the thumbnail to appear
  451. list_display = ('admin_thumb', 'name', 'likes_cat_gifs')
  452. # Optionally tell IndexView to add buttons to a different column (if the
  453. # first column contains the thumbnail, the buttons are likely better off
  454. # displayed elsewhere)
  455. list_display_add_buttons = 'name'
  456. """
  457. Set 'thumb_image_field_name' to the name of the ForeignKey field that
  458. links to 'wagtailimages.Image'
  459. """
  460. thumb_image_field_name = 'avatar'
  461. # Optionally override the filter spec used to create each thumb
  462. thumb_image_filter_spec = 'fill-100x100' # this is the default
  463. # Optionally override the 'width' attribute value added to each `<img>` tag
  464. thumb_image_width = 50 # this is the default
  465. # Optionally override the class name added to each `<img>` tag
  466. thumb_classname = 'admin-thumb' # this is the default
  467. # Optionally override the text that appears in the column header
  468. thumb_col_header_text = 'image' # this is the default
  469. # Optionally specify a fallback image to be used when the object doesn't
  470. # have an image set, or the image has been deleted. It can an image from
  471. # your static files folder, or an external URL.
  472. thumb_default = 'https://lorempixel.com/100/100'
  473. .. _modeladmin_list_display_add_buttons:
  474. ---------------------------------------
  475. ``ModelAdmin.list_display_add_buttons``
  476. ---------------------------------------
  477. **Expected value**: A string matching one of the items in ``list_display``.
  478. If for any reason you'd like to change which column the action buttons appear
  479. in for each row, you can specify a different column using
  480. ``list_display_add_buttons`` on your ``ModelAdmin`` class. The value must
  481. match one of the items your class's ``list_display`` attribute. By default,
  482. buttons are added to the first column of each row.
  483. See the ``ThumbnailMixin`` example above to see how
  484. ``list_display_add_buttons`` can be used.
  485. .. _modeladmin_index_view_extra_css:
  486. -----------------------------------
  487. ``ModelAdmin.index_view_extra_css``
  488. -----------------------------------
  489. **Expected value**: A list of path names of additional stylesheets to be added
  490. to the ``IndexView``
  491. See the following part of the docs to find out more:
  492. :ref:`modeladmin_adding_css_and_js`
  493. .. _modeladmin_index_view_extra_js:
  494. -----------------------------------
  495. ``ModelAdmin.index_view_extra_js``
  496. -----------------------------------
  497. **Expected value**: A list of path names of additional js files to be added
  498. to the ``IndexView``
  499. See the following part of the docs to find out more:
  500. :ref:`modeladmin_adding_css_and_js`
  501. .. _modeladmin_index_template_name:
  502. ---------------------------------------
  503. ``ModelAdmin.index_template_name``
  504. ---------------------------------------
  505. **Expected value**: The path to a custom template to use for ``IndexView``
  506. See the following part of the docs to find out more:
  507. :ref:`modeladmin_overriding_templates`
  508. .. _modeladmin_index_view_class:
  509. ---------------------------------------
  510. ``ModelAdmin.index_view_class``
  511. ---------------------------------------
  512. **Expected value**: A custom ``view`` class to replace
  513. ``modeladmin.views.IndexView``
  514. See the following part of the docs to find out more:
  515. :ref:`modeladmin_overriding_views`