mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #14661 -- Clarified the handling of initial data injected via custom SQL.
This is BACKWARDS INCOMPATIBLE CHANGE for anyone relying on SQL-injected initial data in a test case. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15239 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1237,6 +1237,15 @@ documentation<dumpdata>` for more details.
|
||||
Fixtures with other names can always be installed manually using
|
||||
the :djadmin:`manage.py loaddata<loaddata>` command.
|
||||
|
||||
.. admonition:: Initial SQL data and testing
|
||||
|
||||
Django provides a second way to insert initial data into models --
|
||||
the :ref:`custom SQL hook <initial-sql>`. However, this technique
|
||||
*cannot* be used to provide initial data for testing purposes.
|
||||
Django's test framework flushes the contents of the test database
|
||||
after each test; as a result, any data added using the custom SQL
|
||||
hook will be lost.
|
||||
|
||||
Once you've created a fixture and placed it in a ``fixtures`` directory in one
|
||||
of your :setting:`INSTALLED_APPS`, you can use it in your unit tests by
|
||||
specifying a ``fixtures`` class attribute on your :class:`django.test.TestCase`
|
||||
|
||||
Reference in New Issue
Block a user