Default ordering of the model

The default ordering for the object, for use when obtaining lists of objects:

class Run(models.Model):
    date = models.DateField()

    class Meta:
        ordering = ['-date']

Creating custom management command

Place it in management/commands


The simplest command:

from import BaseCommand

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

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

To see commands that may be used with

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

./ createsuperuser

Run initial database migration with South when database already exists

./ migrate myapp --fake