Actions

Mass Update

Update one or more fields of the selected queryset to a common value and/or apply a transform_operations to selected field.

validate use obj.save() instead of obj._default_manager.update. Slower but required in some cases (To run some business logic in save() and clean() Manadatory if use Transform Operation
unique_transaction
Please see the changelog

Screenshot

_images/mass_update.png

Transform Operation

Please see the changelog

Is possible to update fields applying function. django-adminactions comes with a predefined set of functions. You can anyway register your own functions

common to all models

set set the value
set null set the value to null (only available if the field has null=True

django.db.models.CharField

upper convert to uppercase
lower convert to lowercase
capitalize capitalize first character
capwords capitalize each word
swapcase swap the case
trim remove leading and trailing whitespace

django.db.models.IntegerField

add add the value passed as arg to the current value of the field
sub subtract the value passed as arg to the current value of the field
add_percent add the X percent to the current value
sub_percent subtract the X percent from the current value

django.db.models.BooleanField

swap invert (negate) the current value

django.db.models.NullBooleanField

swap invert (negate) the current value

django.db.models.EmailField

change domain set the domain (@?????) to common value

django.db.models.URLField

change domain set the protocol (????://) to common value

Export as CSV

Export selected queryset as csv file. (see csv)

Available options: (see Dialects and Formatting Parameters).

See also

Are you looking for the export_as_csv internal api? .

header add the header line to the file
delimiter A one-character string used to separate fields. It defaults to ‘,’. (see csv.Dialect.delimiter)
quotechar A one-character string used to quote fields containing special characters, such as the delimiter or quotechar, or which contain new-line characters. It defaults to ‘”’. (see csv.Dialect.quotechar)
quoting Controls when quotes should be generated by the writer and recognised by the reader. (see csv.Dialect.quoting)
escapechar A one-character string used by the writer to escape the delimiter. (see csv.Dialect.escapechar)
datetime_format How to format datetime field. (see strftime and strptime Behavior)
date_format How to format date field. (see strftime and strptime Behavior)
time_format How to format time field. (see strftime and strptime Behavior)
columns Which columns will be included in the dump

Screenshot

_images/export_as_csv.png

Streaming CSV Response

When a very large/complex dataset is exported, it may take be useful to stream the response row by row instead of the whole file.

To enable this functionality by default, set the django settings.ADMINACTIONS_STREAM_CSV to True (default: False).

Behind the scenes, this attaches an iterator as the response content (using a StreamingHttpResponse if django >= 1.6 and HttpResponse otherwise); the iterator simply yields a new csv row for each queryset iteration.

The benefit of this approach is a shorter initial response which unblocks the customer from request/response and he is free to do other things while waiting for the download to finish.

See also

`csv_defaults`_

Export as Fixture

Export selected queryset as fixtures using any registered Serializer.

Note

this is not the same as django’s command dumpdata because it can dump also the Foreign Keys.

use natural key If true use natural keys.
dump on screen Dump on screen instead to show Save as popup
indent Indentation value
serializer Serializer to use. (see Serialization formats)
add_foreign_keys If checked export foreign keys too, otherwise act as standard dumpdata

Screenshot

_images/export_as_fixture.png

Export Delete Tree

Please see the changelog

Export all the records that belong selected queryset using any registered Serializer.

This action is the counterpart of export_as_fixture, where it dumps the queryset and it’s ForeignKeys, export_delete_tree all the records that belong to the entries of the selected queryset. see export_as_fixture for details

use natural key If true use natural keys.
dump on screen Dump on screen instead to show Save as popup
indent Indentation value
serializer Serializer to use. (see Serialization formats)
add_foreign_keys If checked export dependent objects too.

Screenshot

_images/export_as_fixture.png

Export as Excel

Please see the changelog

Export selected queryset as Excel (xls) file.

Available options:

header add the header line to the file
columns Which columns will be included in the dump

Graph Queryset

Graph selected queryset.

Graph type Graph type to use
Group by and count by: Grouping field

Screenshot

_images/graph_pie.png

Screenshot

_images/graph_bar.png

Merge Records

Please see the changelog

Sometimes you need to “merge” two records maybe because they represent the same business object but were create double by mistake. This action allow you to selectively merge two records and move dependencies from one record to the other one.

Screenshots

Step 1

_images/merge_1.png

Step 2

_images/merge_2.png

Limitations/TODO

  • merge doesn’t work for models related with on_delete=Protect (see #85)
  • ImageField is not supported (see #95)
  • ManyToManyField is not supported (see #108)