views:

19

answers:

1

Hello everyone,

My database has two types of entries: The very dynamic (users, comments, etc) and the more static (email templates, flat-pages).

During testing I want a clean DB but with the real 'semi-static' data.

Is there a way to make Django's testing system to load parts of the original DB ?

Thanks

+2  A: 

Use fixtures.

http://www.djangoproject.com/documentation/models/fixtures/

Put data you need into fixtures and they will be loaded every time test database is built.

gruszczy
Not sure I understand how I dynamically get that data from the real db. Do I need to manually create them every time ? Or is there a way to make the tests auto-extract them ?
Murkin
No, create a simple python script, that will select required data from the database and then build fixtures. Those fixtures will be inserted into the test database every time it is created.
gruszczy