Administration, custom management commands

In addition to using the fabfile commands, an Abelujo administrator may need to work manually on websites. Here some tips and pointers.


all commands have to be run at the project root and with the python virtualenv activated (workon abelujo or source bin/activate) unless stated otherwise.

Add and delete users

There is no graphical way to add users yet, but a Django management command:

./ createsuperuser

this will ask for a user name and an email adress.

Delete a superuser:

./ deletesuperuser <username>

And list all:

./ listsuperusers

Change a user password

A user connected to his session can change his password. Go to the Database interface and see a drop-down button at the top right corner with an option to change the password.

An administrator can also do it from the command line:

./ changepassword username

Re-initialize quantities to zero

Use our custom management command reset_quantities:

./ reset_quantities

Remove (substract) quantities of cards from a file


./ remove_quantities -i path-to-file.csv [-q 1]

This can happen: you are given a file with several columns (at least an ISBN and a quantity, integer field) and you are asked to remove the given quantities for each ISBN.

Variation: ignore the quantities in the file and substract 1 or a given, set number. Use the -q 1 option.

The file doesn’t need to be a .csv really.

Managing inventories

To apply an inventory from the command line, use apply_inventories --ids [id id,id,…].

Its argument is either one id or a coma-separated list of ids (no spaces in between).

To appy all open inventories, use --all, possibly with --exclude.

To archive a bunch of inventories in a row (archive and close), use archive_inventories --all --ids.

These command ask for confirmation before applying the changes, unless you bypass the confirmation prompt with --yes.

Import a csv file of ISBNs and quantities

The CSV file has two columns: the ISBN and the quantity.

This command will search for the bibliographic information of this ISBN and save it to the database with the given quantity.

You can export your Excel or LibreOffice calc sheet into csv, preferably with a ; as separator.

Use the import_isbns command:

./ import_isbns -i myfile.csv


  • -l to choose the language of the bibliographic search (a french source by default)
  • -s <id> to choose a shelf.

The script will search each ISBN on the datasource, create a Card object, and save the given quantity into the default Place. Consequently, before running the script, you must choose the appropriate default place.

If an ISBN is not found, the script carries on and prints all the ones not found at the end.

update january, 2020: the script was not indempotent but is now. You can run it twice in a row, it will not add up the quantities, only set them.

If you need more features, get in touch.

Update all the books with Dilicom

You need this if you used Abelujo before subscribing to Dilicom.

You must have Dilicom credentials.

You can update all the books data:

  • distributor
  • publisher
  • thickness, height, width, weight
  • parution date
  • theme
  • etc


DILICOM_USER=foo DILICOM_PASSWORD=bar ./ update_all_with_dilicom

(By using explicitely the Dilicom scraper, we use its feature of bulk import by batches of 100).

Delete unused publishers

This can happen specially after the full update from Dilicom. Run:

./ delete_unused_publishers

There is a confirmation prompt.

Export all books in stock


./ export_stock --format csv

This will create a CSV file with all cards in stock with a quantity > 0.

Extract compta about sells of the year


./ <date from yyyy-mm-dd> <date end>

It creates a CSV with these columns: “sell id”, “date”, “ISBN”, “sell amount HT”, “VAT”, “amount with taxes (TTC)”, “payment method”.

In the future, we should compute more stuff.

Get statistics on shelves and stock rotation

The data given by this management command are not yet available in the web interface (as of 2023-10-24).


./ stats_ventilation

Example output:

Littérature / SF / Fantasy
références: 270 volumes: 332
valeur stock: 4315.19
rotation: 1.1
rotation jours: 333.8
nouveautés: références: 10 volumes: 11 % volumes: 3.32 valeur: 190.9 % valeur: 4.43
fonds: références: 56 volumes: 62 % volumes: 18.68 valeur: 1077.1 % valeur: 24.97


nouveautés rotation: 1.8 (CA ce mois 2567.74 / valeur stock (moyenne mois) 1434.1925)
nouveautés rotation jours: 203.87
fonds rotation: 0.54 (CA ce mois 8232.55 / valeur stock (moyenne mois) 15403.4675)
fonds rotation jours: 682.94

For each shelf, we get:

  • its number of references and volumes
  • the rotation of the shelf, in two formats, ratio or number of days (it gets 333.8 days for this shelf to be completed sold).
  • some numbers on new and old stock for this shelf (books whose publication date is <1 month and >12 months respectively)

Finally, we get the rotation for new stock and old stock globally. This data is computed with this month’s sells, the stock value used for the computation is the global stock value expressed as a mean for a month (hence the global value divided by 12). This might be subject to change.

Other management commands

Transforming a shelf to a place:

./ shelf2place --shelf=<id> [--can_sell true/false]

Use case: we did the inventory, and it turned out that “mezzanine” should be the stocking place, not a shelf (so we can know what’s in the reserve).

Transform the shelf into a place of the same name with ALL the cards from the default place. We don’t create a movement object.

Consequently the moved cards won’t have an associated shelf anymore. The shelf object will be deleted, and the inventories made against it too. You might want to save or export your DB beforehand.