See the page about initdb in the Developer's Guide.

The command performs three actions in one:

  • it flushes the database specified in your, i.e. issues a DROP TABLE for every table used by your application.

  • it runs Django's migrate command to re-create all tables,

  • it runs Django's loaddata command to load the specified fixtures.

This also adds a warning filter to ignore Django's warnings about empty fixtures. (See Django ticket #18213).

This reimplements a simplified version of Django's reset command, without the possibility of deleting only some data (the thing which caused so big problems that Django 1.3. decided to deprecate this command.

Deleting all data and table definitions from a database is not always trivial. It is not tested on PostgreSQL. In MySQL we use a somewhat hackerish and MySQL-specific DROP DATABASE and CREATE DATABASE because even with constraint_checks_disabled we had sporadic errors. See 2015-03-28

Note that Lino does not use Django's migration framework, so initdb runs Django's migrate command with the --run-syncdb option which "allows creating tables for apps without migrations". The Django docs add that "While this isn’t recommended, the migrations framework is sometimes too slow on large projects with hundreds of models." Yes, we go the way which is not recommended.

(This module's source code is available here.)


foralltables(using, cmd)


Command([stdout, stderr, no_color, force_color])

Flush the database and load the specified fixtures. = True

class, stderr=None, no_color=False, force_color=False)


Flush the database and load the specified fixtures.