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 9457,ContextType in of limit_choices_to clause causing error during initial syncdb,bnospam@…,nobody,"I'm getting the following error (on an empty database): {{{ $ python manage.py syncdb ... (traceback) ... sqlite3.OperationalError: no such table: django_content_type }}} My INSTALLED_APPS includes ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.admin', 'django.contrib.sites', ..., 'Pl', 'Proc') The offending line seems to be: {{{ # pl/models.py proc = models.ForeignKey(BaseModel, limit_choices_to={ 'content_type': ContentType.objects.get_for_model(Proc) }) # where class Proc(BaseModel): # ... }}} The traceback is as follows (modified slightly to simplify class names): {{{ Traceback (most recent call last): File ""./manage.py"", line 11, in execute_manager(settings_web) File ""/Library/Python/2.5/site-packages/django/core/management/__init__.py"", line 340, in execute_manager utility.execute() File ""/Library/Python/2.5/site-packages/django/core/management/__init__.py"", line 295, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File ""/Library/Python/2.5/site-packages/django/core/management/base.py"", line 77, in run_from_argv self.execute(*args, **options.__dict__) File ""/Library/Python/2.5/site-packages/django/core/management/base.py"", line 95, in execute self.validate() File ""/Library/Python/2.5/site-packages/django/core/management/base.py"", line 122, in validate num_errors = get_validation_errors(s, app) File ""/Library/Python/2.5/site-packages/django/core/management/validation.py"", line 28, in get_validation_errors for (app_name, error) in get_app_errors().items(): File ""/Library/Python/2.5/site-packages/django/db/models/loading.py"", line 128, in get_app_errors self._populate() File ""/Library/Python/2.5/site-packages/django/db/models/loading.py"", line 57, in _populate self.load_app(app_name, True) File ""/Library/Python/2.5/site-packages/django/db/models/loading.py"", line 72, in load_app mod = __import__(app_name, {}, {}, ['models']) File ""/Users/brian/dev/trunk/apps/ple/models.py"", line 238, in class Ple(models.Model): File ""/Users/brian/dev/trunk/apps/ple/models.py"", line 246, in Pl limit_choices_to={ 'content_type': ContentType.objects.get_for_model(Proc) }) File ""/Library/Python/2.5/site-packages/django/contrib/contenttypes/models.py"", line 28, in get_for_model defaults = {'name': smart_unicode(opts.verbose_name_raw)}, File ""/Library/Python/2.5/site-packages/django/db/models/manager.py"", line 96, in get_or_create return self.get_query_set().get_or_create(**kwargs) File ""/Library/Python/2.5/site-packages/django/db/models/query.py"", line 326, in get_or_create return self.get(**kwargs), False File ""/Library/Python/2.5/site-packages/django/db/models/query.py"", line 298, in get num = len(clone) File ""/Library/Python/2.5/site-packages/django/db/models/query.py"", line 154, in __len__ self._result_cache = list(self.iterator()) File ""/Library/Python/2.5/site-packages/django/db/models/query.py"", line 269, in iterator for row in self.query.results_iter(): File ""/Library/Python/2.5/site-packages/django/db/models/sql/query.py"", line 206, in results_iter for rows in self.execute_sql(MULTI): File ""/Library/Python/2.5/site-packages/django/db/models/sql/query.py"", line 1700, in execute_sql cursor.execute(sql, params) File ""/Library/Python/2.5/site-packages/django/db/backends/util.py"", line 19, in execute return self.cursor.execute(sql, params) File ""/Library/Python/2.5/site-packages/django/db/backends/sqlite3/base.py"", line 167, in execute return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: no such table: django_content_type }}} Python: 2.5.1 OS: OS X Cheers!",,closed,"Database layer (models, ORM)",1.0,,invalid,"contexttype, database",,Unreviewed,0,0,0,0,0,0