moving django site to another server
Question: I want to move my django site to another machine. (I want to start with empty
DB)  
I thought i'll be done with the following steps.

  * copy all files 

setup all tools(django,python,..etc)

run syncdb

When I run `manage.py syncdb`, it complains some table(such as
django_content_type) doesn't exist.  
I looked at the DB, indeed there are no tables in the DB.

I tried `recreate project`(startproject) or `recreate app`(startapp). (But
they fail because the project or app name is already taken.)

What should I do?  
The reason I can think of is mysql being upgraded to 5.5.27 (default to
innodb)

* * *
    
    
    $ python manage.py syncdb
    Traceback (most recent call last):
      File "manage.py", line 10, in <module>
        execute_from_command_line(sys.argv)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
        utility.execute()
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/base.py", line 231, in execute
        self.validate()
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate
        num_errors = get_validation_errors(s, app)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/core/management/validation.py", line 30, in get_validation_errors
        for (app_name, error) in get_app_errors().items():
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/loading.py", line 158, in get_app_errors
        self._populate()
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/loading.py", line 64, in _populate
        self.load_app(app_name, True)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/loading.py", line 88, in load_app
        models = import_module('.models', app_name)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
        __import__(name)
      File "/home/ubuntu/Documents/aLittleArtist/django/gallery/models.py", line 152, in <module>
        ALBUM_IMAGE_TYPE = ContentType.objects.get(app_label="gallery", model="AlbumImage")
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/manager.py", line 131, in get
        return self.get_query_set().get(*args, **kwargs)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/query.py", line 361, in get
        num = len(clone)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/query.py", line 85, in __len__
        self._result_cache = list(self.iterator())
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/query.py", line 291, in iterator
        for row in compiler.results_iter():
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 763, in results_iter
        for rows in self.execute_sql(MULTI):
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
        cursor.execute(sql, params)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/backends/util.py", line 40, in execute
        return self.cursor.execute(sql, params)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 114, in execute
        return self.cursor.execute(query, args)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
        self.errorhandler(self, exc, value)
      File "/home/ubuntu/virtualenvs/aLittleArtist/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
        raise errorclass, errorvalue
    django.db.utils.DatabaseError: (1146, "Table 'gallery_db.django_content_type' doesn't exist")
    


Answer: ALBUM_IMAGE_TYPE = ContentType.objects.get(app_label="gallery",
model="AlbumImage")

This line was the culprit.  
seems like the above line attempts to do DB query before any DB table is
created.

I removed the line and relevant code and let syncdb run. and did migrate with
south.

