On Sun, Jan 25, 2009 at 7:13 PM, Karen Tracey <kmtra...@gmail.com> wrote: > On Sun, Jan 25, 2009 at 7:03 PM, Todd O'Bryan <toddobr...@gmail.com> wrote: >> >> I've been trying to convert my apps to use the relative imports from >> __future__ and have noticed a problem. I think it may be something >> Django is doing, but I'm not sure. >> >> In the __init__.py module inside an app, I have >> >> from __future__ import absolute_import >> >> from ..another_app.models import blah >> >> This causes an error when I try to load a page that uses it, with the >> error message: >> >> No module named another_app.models >> >> I looked up the absolute_import PEP, and it uses the __name__ value to >> figure out relative imports. So I tried printing __name__. When the >> file is first imported, the name is 'project.app', but later on, after >> the server starts running (and when it causes the error in >> page-loading) the name has changed to 'project.app.' with an extra dot >> at the end. >> >> Is Django doing this or is it happening in the bowels of my code >> somewhere? If Django is doing this, does it have to since it will mess >> up absolute_import users? > > Sounds related to: > > http://code.djangoproject.com/ticket/8193 > > Karen >
That's exactly what it is, and that hasn't been fixed because people don't think it's really a bug. OK, just note that it will be a bug at some point in the future, because it doesn't work with absolute_import. Especially if we want apps to be self-contained (i.e., be able to do relative imports rather than absolute imports), this will eventually become an issue. Thanks for pointing out the issue, Karen. I just decided to hold off on absolute_import, even though I think it makes imports much prettier. :-) Todd --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---