CHANGES pour la version 0.5
[auf_django_references.git] / auf / django / references / management / __init__.py
CommitLineData
652c5d02
EMS
1# encoding: utf-8
2
3from django.db import connection
4from django.db.models import get_models, signals
5
6import auf.django.references.models
7
8def post_syncdb(sender, **kwargs):
9 if connection.vendor == 'mysql':
10 print u'Création des vues pour les données de référence...'
11 cursor = connection.cursor()
12 for model in get_models():
13 if model.__module__ == 'auf.django.references.models':
14 table_name = model._meta.db_table
15 cursor.execute(
16 'CREATE OR REPLACE VIEW `%s` AS SELECT * FROM datamaster.`%s`' %
17 (table_name, table_name)
18 )
19
20signals.post_syncdb.connect(post_syncdb, sender=auf.django.references.models)