how to organize models

33 views
Skip to first unread message

Jojo

unread,
Aug 11, 2012, 1:57:38 PM8/11/12
to django...@googlegroups.com
Hi, I'm developing my first web application with Django. The model is growing up quite fast and I started to split the code in different files I putted under models directory with its __init__.py file. Everything works fine, but syncdb doesn't recognize new models, and consequently doesn't create new tables.
What is the best practice to organize models?
I thought to create different applications, but in this case I don't know how to manage relations across differents applications.

What do you suggest?

Thanks in advance.

Alexis Roda

unread,
Aug 11, 2012, 6:25:14 PM8/11/12
to django...@googlegroups.com
Al 11/08/12 15:57, En/na Jojo ha escrit:
> Hi, I'm developing my first web application with Django. The model is
> growing up quite fast and I started to split the code in different files
> I putted under models directory with its __init__.py file. Everything
> works fine, but syncdb doesn't recognize new models, and consequently
> doesn't create new tables.

You should import the models from __init__.py and add to every model

class Meta :
app_label = "your_app_label"


https://docs.djangoproject.com/en/1.4/ref/models/options/#app-label
https://docs.djangoproject.com/en/1.4/topics/db/models/#meta-options


HTH

Jojo

unread,
Aug 12, 2012, 4:32:39 PM8/12/12
to django...@googlegroups.com
It works!

Thank you very much!
Reply all
Reply to author
Forward
0 new messages