Splitting models.py won't install models

0 views
Skip to first unread message

Alistair Marshall

unread,
Oct 28, 2008, 5:36:02 AM10/28/08
to Django users
I have been trying to split my models.py file into several smaller
more manageable files. I have created a folder named models, an in
there, created a __init__.py file which contains:

from other import *
from streams import *
from units import *

I have then split my models into the three files making sure to add
app_label = 'process' to the metatag of each model. Then when I run
'python manage.py syncdb', It runs through and creates tables for
models from other application but doesn't create any models to do with
my process app.

If I insert a syntax error into one of my models, it does raise an
error when I syncdb.
If I remove app_label, it does not raise an error or change the
behaviour in any way.

am I missing anything else?
any other suggestions?

Thanks
Alistair

patrickk

unread,
Oct 28, 2008, 9:43:23 AM10/28/08
to Django users
you could try changing the import in __init__.py to someting like
this:
from app_name.models.model_file import Model1, Model2, ...
e.g.
from library.models.material import Material, MaterialImage

... might work.

patrick.


On 28 Okt., 10:36, Alistair Marshall <runninga...@googlemail.com>
wrote:

Alistair Marshall

unread,
Oct 28, 2008, 11:53:23 AM10/28/08
to Django users
On Oct 28, 1:43 pm, patrickk <sehmasch...@gmail.com> wrote:
> you could try changing the import in __init__.py to someting like
> this:
> from app_name.models.model_file import Model1, Model2, ...
> e.g.
> from library.models.material import Material, MaterialImage
>
> ... might work.
>
Thanks for your reply,

unfortunately it made no difference.
If I miss type a model name or try to import from a non existent file,
I get an error (as expected) however if all is typed correct I get no
error but my models are still not inserted into my database.

any other ideas?

Thanks again

Rock

unread,
Oct 28, 2008, 12:31:40 PM10/28/08
to Django users
I tried to do this several months ago during the run up to the 1.0
release and, at that time, the capability was broken. Furthermore I
recall having a discussion with some core developer that it was not on
the short list to fix for 1.0. I didn't submit a ticket for this, but
it may have been because someone else had already done so. I suggest
searching the tickets before spending any more time trying to make
this work.

patrickk

unread,
Oct 29, 2008, 3:48:55 AM10/29/08
to Django users
strange. I´m using this for one of my applications and it works fine.

hers´s my setup:

/library/
__init__.py
admin.py
views.py
/models/
__init__.py
addon.py
camera.py
material.py

__init__.py (in the models-directory):
from library.models.material import Material, MaterialImage
from library.models.camera import Camera
from library.models.addon import AddOn

material.py (for example):
class Material(models.Model):
....
class Meta:
app_label = "library"

admin.py:
from library.models.material import Material, MaterialImage
...
admin.site.register(Material, MaterialOptions)
...


I´m using the current trunk.

hope that helps,
patrick

Alistair Marshall

unread,
Oct 29, 2008, 7:11:04 AM10/29/08
to Django users
Ok, perhaps this is a pinax issue?

I would not have thought that it would have made a difference but I'll
try asking on the pinax list.

Thanks for your help

Alistair Marshall

unread,
Nov 1, 2008, 10:54:48 AM11/1/08
to Django users
Right I managed to fix it and feel really stupid at the same time but
I thought I would post here in case anyone else has the same issue

my mistake was using
class meta:

and not
class Meta:

doh! got to love case sensitivity.

Thanks to all that offered suggestions
Alistair

---
Alistair Marshall
http://www.thatscottishengineer.co.uk
Reply all
Reply to author
Forward
0 new messages