title: Temporary models in django
body: <p>In one celery task I need to create temporary table in database. In <a href="http://blog.roseman.org.uk/2010/04/13/temporary-models-django/" rel="nofollow">this article</a> Daniel Roseman explained how to create one. But this solution does not work in Django 1.9. I tried to look into Django docs and Google but I was unable to find anything useful.</p>
  
  <p>Code from mentioned article which worked in Django 1.8:</p>
  
  <pre><code>from django.db import models, cursor
  from django.contrib.contenttypes.management import update_contenttypes
  from django.core.management import call_command
  
  class TempCustomerAddress(models.Model):
      address = models.ForeignKey('accounts.Address')
      legacy_id = models.CharField(max_length=12, unique=True)
  
      class Meta:
          app_label = 'utils'
  
  
  class Command(NoArgsCommand):
  
      def handle_noargs(self, **options):
          models.register_models('utils', TempCustomerAddress)
          models.signals.post_syncdb.disconnect(update_contenttypes)
          call_command('syncdb')
  
          # ... do importing and stuff referring to TempCustomerAddress ...
  
          cursor = connection.cursor()
          cursor.execute('DROP TABLE `utils_tempcustomeraddress`')
  </code></pre>