﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
11264	"""from django.db import models"" clobbered in functions inside __init__.py of installed apps"	Antti Kaihola	nobody	"If an app `myapp` has the following `__init__.py`:

{{{
from django.db import models
def myfunc():
    assert models.__package__ == 'django.db.models', (
        'models is %r instead of django.db.models' % models)
}}}

then calling `myapp.myfunc()` throws:

{{{
AssertionError:
  models is <module 'myapp.models' from 'myapp/models.pyc'>
  instead of django.db.models
}}}

This happens only if
 * `myapp` is in INSTALLED_APPS
 * `myfunc` is in `myapp/__init__.py`, not some other module in it
 * Django is r10088 or later (thanks, git bisect)

This breaks at least Satchmo from a few months back for me, probably trunk too.

r10088 claims to have fixed all dynamic imports in Django by backporting `importlib` from Python 2.7."	Bug	closed	Database layer (models, ORM)	dev	Normal	invalid	importing	miracle2k	Accepted	0	0	0	0	0	0
