On Thu, 2006-05-04 at 00:39 +1000, Malcolm Tredinnick wrote:
> On Wed, 2006-05-03 at 16:29 +0200, Honza Král wrote:
> > BEGIN;
> > COMMIT;
> > is the output of manage.py sql app (empty sql script for postgreSQL)
> > 
> > I am fairly new to python, so I completely don't mind trivial questions,
> > in app/models/__init__.py I have:
> > ----
> > # base models
> > from proj.app.models.base import *
> > # models derived from base
> > from proj.app.models.more_models import *
> > 
> > # I even added
> > __all__ = [ 'List', 'Of', 'All', 'My', 'Model', 'Classes' ]
> > -----
> > and it still wouldn't work
> > 
> > if I run shell and try to use my models from there ( from
> > proj.app.models import * ) everything works OK, dir shows all my model
> > classes...
> 
> I thought this should work, but I must admit that a quick test I did
> just now completely failed. Wait for the Earth to turn a little more on
> its axis: Luke Plant has a bit of experience in this area (every time it
> broke, he screamed), so I think we are missing something obvious. Give
> it some time and see if Luke notices this thread (or somebody else spots
> what's wrong).

Some further developments here: I was comparing aikhola's example on the
Wiki page he just made
(http://code.djangoproject.com/wiki/CookBookSplitModelsToFiles ) to my
quick test. He included the app_label attribute in the Meta class. I was
not. Including that fixes the problem... it all works.

I'm not sure that is the ideal solution, since (a) it seems to be
entirely undocumented, and (b) it is unnatural; if "import myapp.models"
puts the model into the namespace, I would expect any introspection code
to pick it up. Having to add an attribute to say "if you're completely
stuck, here's a clue" seems unfortunate (and if you misspell the app
name, for example, and it doesn't match your directory, it's game over
-- no model for you).

So we might still be searching for the right implementation (or I might
be wrong about this being not ideal), but Django as it stands at the
moment *can* support multiple files in a models directory. You just need
to sprinkle the secret sauce liberally.

Cheers,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to