Login

Tag "manage.py"

Snippet List

Link Media Command

A command for manage.py which scans through installed applications the way admin.autodiscover does, just looking for media folders. It then creates a symbolic link to the media under MEDIA_ROOT/app_name. Usage: save in an apps management/commands folder and run with "python manage.py linkmedia" Only works on *nix systems, but there should be an equivilent way to do this with windows using .lnk files.

  • manage.py
  • media
  • command
  • symlink
Read More

Command to dump data as a python script

This creates a fixture in the form of a python script. Handles: 1. `ForeignKey` and `ManyToManyField`s (using python variables, not IDs) 2. Self-referencing `ForeignKey` (and M2M) fields 3. Sub-classed models 4. `ContentType` fields 5. Recursive references 6. `AutoField`s are excluded 7. Parent models are only included when no other child model links to it There are a few benefits to this: 1. edit script to create 1,000s of generated entries using `for` loops, python modules etc. 2. little drama with model evolution: foreign keys handled naturally without IDs, new and removed columns are ignored The [runscript command by poelzi](http://code.djangoproject.com/ticket/6243), complements this command very nicely! e.g. $ ./manage.py dumpscript appname > scripts/testdata.py $ ./manage.py reset appname $ ./manage.py runscript testdata

  • dump
  • manage.py
  • serialization
  • fixtures
  • migration
  • data
  • schema-evolution
  • management
  • commands
  • command
Read More

Alternate method of autoloading Django models in ipython

This is a little improvement to the [idea](http://www.djangosnippets.org/snippets/540/) from sheats a few days ago. I like it over the previous solutions because it doesn't involve doing anything other than running `./manage.py shell` inside your project directory. You don't have to create any files anywhere or remember to call anything, and `ipython` still works fine outside of a Django project. Throw this code in `~/.ipython/ipy_user_conf.py` (`ipythonrc` has apparently been deprecated).

  • django
  • model
  • manage.py
  • shell
  • ipython
Read More

sqlallall.py

A simple script to run 'manage.py sqlall' on every app in a project.

  • sql
  • manage.py
  • sqlall
Read More
Author: jkl
  • 0
  • 2

6 snippets posted so far.