title: Python: missing class attribute __module__ when using type()?
body: <p>I'm attempting to dynamically construct some classes which are subclasses of django's models.Model.  My code looks like this:</p>
  
  <pre><code>MyModel = type('MyModel', (models.Model,), {
      'field': models.BooleanField()
      })
  </code></pre>
  
  <p>When Django tries to load this, it gives the following exception:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 88, in inner_run
      self.validate(display_num_errors=True)
    File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 249, in validate
      num_errors = get_validation_errors(s, app)
    File "/usr/lib/python2.7/site-packages/django/core/management/validation.py", line 36, in get_validation_errors
      for (app_name, error) in get_app_errors().items():
    File "/usr/lib/python2.7/site-packages/django/db/models/loading.py", line 146, in get_app_errors
      self._populate()
    File "/usr/lib/python2.7/site-packages/django/db/models/loading.py", line 61, in _populate
      self.load_app(app_name, True)
    File "/usr/lib/python2.7/site-packages/django/db/models/loading.py", line 78, in load_app
      models = import_module('.models', app_name)
    File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
      __import__(name)
    File "/home/user/project/app/models.py", line 221, in &lt;module&gt;
      'field': models.BooleanField()
    File "/usr/lib/python2.7/site-packages/django/db/models/base.py", line 38, in __new__
      module = attrs.pop('__module__')
  KeyError: '__module__'
  </code></pre>
  
  <p>It seems like a class constructed using <code>type()</code> isn't getting the <code>__module__</code> member which is present for class defined with <code>class</code>.  What's going on here?</p>