Opened 11 years ago

Closed 11 years ago

#6034 closed (wontfix)

Add boolean option 'load_fixtures' to the django command 'syncdb', default value is True.

Reported by: delimy@… Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Keywords: syncdb
Cc: ringier-dev@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Add boolean option 'load_fixtures' to the django command 'syncdb', default value is True.
We use this option in tests, so load_fixtures=False will not commit a transaction, and we can rollback easily.
There are also other circumstances that we don't want the fixture to load automatically.

Attachments (1)

syncdb_no_fixture.diff (1.3 KB) - added by delimy@… 11 years ago.

Download all attachments as: .zip

Change History (5)

Changed 11 years ago by delimy@…

Attachment: syncdb_no_fixture.diff added

comment:1 Changed 11 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

If you don't want your fixture to be automatically loaded, don't call your fixture initial_data, and manually load the fixture when you need it.

comment:2 Changed 11 years ago by delimy@…

The problem is that if you create a model in, for example, doctest, call_command('sync') will do a commit to database after loading fixtures.
We use rollback instead of flush, so it cause problem.

comment:3 Changed 11 years ago by favo

Cc: ringier-dev@… added
Resolution: wontfix
Status: closedreopened
Triage Stage: UnreviewedDesign decision needed

Hi russellm,

Thanks for your comment. I think it's not bad to give us more control on syncdb command. syncdb --load_fixtures=False # Don't load fixture automatically. Default is True, so don't break current logic.

The only reason we need to do this like Delimy said above is:

we write some new model in doctest, to help us test our related model( think about you need test your generic tag system, you need a main model.)

Create a test model
    >>> class TestModel(models.Model)
    ...     title = xxx
    >>> call_command('sync')

we also changed django test framework to use rollback instead of flush db, which is more friendly(allow you use a exist db data to test rather than put everything to fixture. sometime fixture can't describe our test data, we have database view, something like this.). so the issue is with in syncdb command will call loaddata command. and in loaddata commend logic, it go into another transcation and commit at the end. which break outside transaction.

So we add an option to syncdb command to across, IMO it's not bad, it's cheap. However we can use method instead, of course.

comment:4 Changed 11 years ago by Jacob

Resolution: wontfix
Status: reopenedclosed

I agree with Russ on this -- more options make for more confusing software. If you're running a custom test framework, you should make this change there.

Note: See TracTickets for help on using tickets.
Back to Top