Opened 15 years ago

Closed 11 years ago

#11838 closed New feature (wontfix)

Make syncdb understand "initialdata" directory

Reported by: Deniz Dogan Owned by: Brandon Konkle
Component: Core (Serialization) Version: dev
Severity: Normal Keywords: syncdb loaddata initial_data
Cc: brandon.konkle@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

In many projects I often find the need to load my data from several separate JSON formatted data dumps. This is because it's easier to manage dumps from different models separately. Unfortunately, syncdb only understands one thing and that is a file named initial_data.json. I think it would be better if syncdb looked for that file, uses it if it finds it, otherwise looks for a directory named initialdata and loads all of the files from that directory.

Attachments (2)

ticket11838.diff (19.4 KB ) - added by Brandon Konkle 15 years ago.
ticket11838-2.diff (23.7 KB ) - added by Brandon Konkle 15 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by Russell Keith-Magee, 15 years ago

Triage Stage: UnreviewedAccepted

I can see the value in the idea, but I'd favor something more generic. Rather than making a special case of an 'initialdata' directory, make a directory a valid form for a fixture. That is, the loading sequence for ./manage.py loaddata foo would be something like:

  • foo.json, foo.yaml etc for each registered serializer
  • foo.json.gz, foo.yaml.gz etc (i.e., look for the compressed fixture
  • a directory named foo that may contain fixtures.

This would allow you to split your initial_data fixture over mutliple files as long as you called the fixture directory initial_data, but would also allow any other fixture to follow the same behavior.

comment:2 by Brandon Konkle, 15 years ago

Owner: changed from nobody to Brandon Konkle
Status: newassigned

by Brandon Konkle, 15 years ago

Attachment: ticket11838.diff added

comment:3 by Brandon Konkle, 15 years ago

Has patch: set

I've implemented the feature as Russel described above. My diff includes the changes to the code, tests, and documentation. Also, since this is my first Django contribution, I've added my name to the AUTHORS file. :-) Thanks!

comment:4 by Brandon Konkle, 15 years ago

The patch is not applying correctly because of a bug in Macport's version of Subversion. I am removing the Macports-installed Subversion and compiling it from source. I'll re-submit the diff when I'm done.

by Brandon Konkle, 15 years ago

Attachment: ticket11838-2.diff added

comment:5 by Brandon Konkle, 15 years ago

I've added a revised patch here with the line numbers referenced correctly. Thanks for nothing, Macports! :-)

comment:6 by Brandon Konkle, 15 years ago

Cc: brandon.konkle@… added

comment:7 by Russell Keith-Magee, 15 years ago

Component: UncategorizedSerialization
milestone: 1.2

comment:8 by Chris Beaven, 14 years ago

Severity: Normal
Type: New feature

comment:9 by Julien Phalip, 14 years ago

Patch needs improvement: set

The tests would need to be rewritten using unittests since this is now Django's preferred way.

comment:10 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:11 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:12 by Aymeric Augustin, 11 years ago

Resolution: wontfix
Status: assignedclosed

The new migrations framework doesn't load initial data any more.

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