On Sat, Feb 18, 2012 at 4:46 PM, LJ <ljayad...@gmail.com> wrote:
> I have quite a number of fixtures that I call loaddata to insert
> fixtures into my sqlite database using the following syntax:
>
> python ./manage.py loaddata ./apps/addresses/fixtures/cities.json
> python ./manage.py loaddata ./apps/addresses/fixtures/addresses.json
> ...
>
> I would like to create a script to call all of these, so I can insert
> them all at once.
> I do not want to combine all of the json files.
> To do this, would I create a py script similar to my bootstrap.py
> script?
> My bootstrap.py script executes subprocess.call() on all packages
> listed in my requirements txt file.
> Am I going down the right path with this, or is there an easier way?
>
> L J
>
Management commands. You can write custom management commands, and you
can programatically invoke other management commands:


from django.core.management.base import NoArgsCommand
from django.core import management

class Command(NoArgsCommand):
  help = 'Meta command which calls other commands'

  def handle_noargs(self, **options):
    management.call_command('loaddata', './apps/addresses/fixtures/cities.json')


https://docs.djangoproject.com/en/1.3/howto/custom-management-commands/

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to