What's the proper way to create custom pgsql types for django application to ensure that every time database is produced with syncdb, all custom types are produced just before creating any tables (to ensure that tables may use this kind)?

I additionally use django-evolution, but that is no appropriate solution — it runs after syncdb. I know carrying out a workaround like determining models with standard area types after which creating types and changing column types in evolutions, but that is certainly not nice kind of obscure...

Any idea?

I do not believe there's a method to do that in Django. While you most likely know, there is a post_syncdb signal but no signal for pre_syncdb.

And So I think there's only two options: hacking pre_syncdb signal into Django or make use of an automation tool like Fabric.

Hacking your personal pre_syncdb signal, even when it's the proper way to do that, most likely will not the simple and you've got to keep the patch each new Django release.

However, not just is definitely an automation tool like Fabric simple however it provides other good things about any project.

For example, a percentage of my Fabfile appears like:

def createdb():
    "Create a clean database"
    run('createdb --encoding=UNICODE $(db_name) -O $(db_owner) -U $(db_owner)')
    run('python manage.py syncdb --noinput')

Add something similar to this right before the syncdb:

run('psql -U $(db_owner) $(db_name) < app/sql/custom_types.sql')

and you ought to be all set just by typing:

$ fab createdb


$ fab cluster createdb

to operate the command on all of the machines indexed by your atmosphere known as cluster.