Django

Creating custom management command

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

Place it in management/commands

  polls/
    __init__.py
    models.py
    management/
        __init__.py
        commands/
            __init__.py
            _private.py
            closepoll.py
    tests.py
    views.py

The simplest command:

from django.core.management.base import BaseCommand

class Command(BaseCommand):
    help = 'Example command'

    def handle(self, *args, **options):
        print 'Command example'

To see commands that may be used with manage.py

Just run it and it will output the list.

For instance, if you do not remember how to create an admin it will show that it may be created with

./manage.py createsuperuser

Run initial database migration with South when database already exists

http://stackoverflow.com/questions/3090648/django-south-table-already-exists

./manage.py migrate myapp --fake
Last edited by Artem Dudarev, 2013-10-13 02:01:37. Edit