On Wednesday 03 May 2006 15:39, 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).

The Earth turned (good 'ol Earth)...

It's strange though - the manage.py commands all work for me, and I 
remember someone else having this problem and it not being resolved.  
My setup is as follows:

/myproject
    /myapp
        /models
            __init__.py
            foo.py
            bar.py


In __init__.py, I have:
----------
from foo import Foo, SomeThingElse
from bar import Bar, AnotherSomething
# a few more, but no __all__ line
----------

The only thing I can see there is the (rather nasty) relative imports 
instead of absolute imports.  I suspect it might be something bizarre 
to do with imports e.g. I might have happened to import something 
inside my model files which accidentally fixes it.  Also, it would be 
good to check Python versions (I'm using 2.4).

I don't have time to debug this at the moment (maybe Friday).  Debugging 
it might be slightly difficult -- it seems to be sensitive to 
environment, so debugging with 'print' will probably be the best 
option, rather than trying to use a debugger.

Hopefully this isn't a blocker -- your other code that uses models can 
import from myproject.myapp.models, rather than 
myproject.myapp.models.foo, so reorganising into multiple files later 
won't require any changes to other code.

Luke

-- 
"I spilled spot remover on my dog. Now he's gone." (Steven Wright)

Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/

--~--~---------~--~----~------------~-------~--~----~
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