justinvh / gitpaste

DEPRECATED - GitPaste is a clone of GitHub's Gist.
Other
184 stars 49 forks source link

syncdb w/ default options or options from settings.py #20

Closed jtimberman closed 12 years ago

jtimberman commented 12 years ago

It would be nice to do manage.py syncdb w/ some default options or options from settings.py without having to enter the prompts. It can be "scripted" with echo, but that smells funny :).

justinvh commented 12 years ago

You can actual have initial data upon table creation; these are call fixtures.

https://docs.djangoproject.com/en/dev/howto/initial-data/

You can dump apps specifically and follow the format to create defaults for your project. So, I imagine from the way you are describing your issue you would want something along the lines of:

python manage.py dumpdata > fixtures/initial_data.json

Then probably something along the lines of:

python mange.py syncdb --noinput 

or:

python manage.py loaddata fixtures/intiial_data.json
jtimberman commented 12 years ago

Ah, yup. Got working with fixtures/initial_data.json. Cheers!

jtimberman commented 12 years ago

Fwiw, in case someone else finds this, here's the JSON:

[{
  "model": "auth.user",
  "pk": 1,
  "fields": {
    "username": "allthepastes", 
    "first_name": "All", 
    "last_name": "The Pastes", 
    "is_active": true, 
    "is_superuser": true, 
    "is_staff": true, 
    "last_login": "2012-04-20 05:40:01", 
    "groups": [], 
    "user_permissions": [], 
    "password": "sha1$00000$HAAAAAAAAAAAAAAAASHED", 
    "email": "allthepastes@example.com", 
    "date_joined": "2012-04-20 05:40:01"
  }
}]