Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

Introduction to demo fixtures

Django fixtures

A fixture, in real life, is a piece of furniture in a house, such as a kitchen, that is considered an integral part of the house. Django uses the word to designate a collection of data records that can be loaded into the database of a new site. The Django docs have a whole Topic guide about How to provide initial data for models.

Every plugin can have a subdirectory named fixtures. Django will discover this directory when you run the loaddata command.

fixtures

A subdirectory of a plugin that contains a number of fixture files in different formats to be loaded using the loaddata command.

In Lino we usually don’t write fixtures in XML or JSON but in Python. That’s why our fixtures directories also contain a __init__.py file.

As a future application developer you can learn more about them in Writing Python fixtures.

Demo fixtures

Lino extends Django’s fixtures by defining the concept of demo fixtures.

demo fixtures

The list of fixtures to be loaded by pm prep when a new Lino site gets installed.

For example, the chatter application has the following value for this attribute:

>>> from lino_book.projects.chatter.settings import Site
>>> Site.demo_fixtures
['std', 'demo', 'demo2']

This means that saying pm prep on a site that runs chatter is equivalent to saying pm initdb std demo demo2.

If the new site runs a Lino Così, the list of demo fixtures is different:

>>> from lino_cosi.lib.cosi.settings import Site
>>> Site.demo_fixtures
['std', 'minimal_ledger', 'furniture', 'demo', 'demo2', 'demo3', 'checkdata']

The list of demo fixtures of an application is defined by the application developer in the demo_fixtures site attribute.

Demo fixtures are written by the application developer because the system administrator doesn’t need to know them when setting up a Lino site. The default list of demo fixtures to load for initializing a meaningful demo database can be long and difficult to remember, it can change when an application evolves… These are implementation details, which a system administrator doesn’t want to know.

Further reading