Dynamic geo models

13 views
Skip to first unread message

Guillaume Sueur

unread,
Mar 6, 2009, 7:25:08 AM3/6/09
to geod...@googlegroups.com
Hi,

I have build a quite functionnal Dynamic models loader module, thanks to
Justinn help. I still have a problem though. The syncdb command to
create the table seems to mess up the admin, as it then appear it
english and not in french anymore. This is not a real problem but in
production with mod_python it messes up things.

On the wiki page about dynamic models I saw a workaround to avoid using
syncdb:
def install(model):
from django.core.management import sql, color
from django.db import connection

# Standard syncdb expects models to be in reliable locations,
# so dynamic models need to bypass django.core.management.syncdb.
# On the plus side, this allows individual models to be installed
# without installing the entire project structure.
# On the other hand, this means that things like relationships and
# indexes will have to be handled manually.
# This installs only the basic table definition.

# disable terminal colors in the sql statements
style = color.no_style()

cursor = connection.cursor()
statements, pending = sql.sql_model_create(model, style)
for sql in statements:
cursor.execute(sql)


but it uses a function sql.sql_model_create which doesn't exist anymore.
Is there another one which could make the job ?

Regards,
--
Guillaume

Ariel Mauricio Nunez Gomez

unread,
Mar 6, 2009, 7:52:33 AM3/6/09
to geod...@googlegroups.com
Guillaume,

I ended up violating DRY and just copied/hacked the original syncdb:


Note in line 31 (http://dpaste.de/n7Rf/#l31) I am only iterating over the models of my dynamic app holder.

Regards,

Ariel.
Reply all
Reply to author
Forward
0 new messages