Opened 11 years ago

Closed 10 years ago

#6408 closed (worksforme) syncdb throwing error due content_types

Reported by: crybaby Owned by: nobody
Component: Core (Management commands) Version: 1.0
Severity: Keywords: syncdb content_types
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I have django dev version 6941.

There seems to be a problem with line when I do python

''' syncdb''':

It creates the tables and but fails to populate initial data.

#!/usr/bin/env python
from import execute_manager

# This is for Dos Prompt Start up
    import  settings
except ImportError:
    import sys
    sys.stderr.write("Error: Can't find the file '' in the
directory containing %r. It appears you've customized things.\nYou'll
have to run, passing it your settings module.\n(If the
file does indeed exist, it's causing an ImportError
somehow.)\n" % __file__)

if __name__ == "__main__":

[joe@localhost mysite]$ python syncdb
Traceback (most recent call last):
  File "", line 15, in ?
  File "/usr/lib/python2.4/site-packages/django/core/management/", line 272, in execute_manager
  File "/usr/lib/python2.4/site-packages/django/core/management/", line 219, in execute
  File "/usr/lib/python2.4/site-packages/django/core/management/", line 72, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.4/site-packages/django/core/management/", line 86, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.4/site-packages/django/core/management/", line 168, in handle
    return self.handle_noargs(**options)
  File "/usr/lib/python2.4/site-packages/django/core/management/
commands/", line 95, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive)
  File "/usr/lib/python2.4/site-packages/django/core/management/", line 489, in emit_post_sync_signal
    verbosity=verbosity, interactive=interactive)
  File "/usr/lib/python2.4/site-packages/django/dispatch/", line 358, in send
  File "/usr/lib/python2.4/site-packages/django/dispatch/", line 47, in robustApply
    return receiver(*arguments, **named)
  File "/usr/lib/python2.4/site-packages/django/contrib/contenttypes/", line 21, in update_contenttypes
ValueError: list.remove(x): x not in list

I have commented out this from,

and syncdb and fixtures are working.

I am currently running python 2.4.3 on Fedora 6 and django svn revision # 6980.

Change History (8)

comment:1 Changed 11 years ago by Jacob

Resolution: worksforme
Status: newclosed

I can't reproduce this. Please post more info if you're still having this problem.

comment:2 Changed 11 years ago by lakin.wecker@…

Resolution: worksforme
Status: closedreopened

My friend reproduced this recently on Mac OSX, 10.4 python 2.5 using an sqlite3 database and django trunk r7639. I have the copy of the code that produces it. The core issue is strange, but is due to [source:django/trunk/django/contrib/contenttypes/]

    content_types = list(ContentType.objects.filter(app_label=app.__name__.split('.')[-2]))

Apparently, the first call to objects.filter after a clear_cache() call will always return an empty list (even tho there are actually content_types in the database.) Duplicating the filter call (one right after the next) will fix the issue ... _or_, commenting out the clear_cache will also fix it. I suspect there is an underlying bug in the QuerySet caching on OSX and sqlite3. But I can't be totally sure. Given some guidance I'd be glad to try to track down the issue, but I don't have OSX in front of me right now.

comment:3 Changed 11 years ago by lakin.wecker@…

On the other hand, he may have a screwy python install. We're now seeing other wierdness from his django/python install and will be investigating it. Please feel free to re-close this ticket. If and when we figure out what's wrong we'll update here.

comment:4 Changed 11 years ago by Russell Keith-Magee

Resolution: invalid
Status: reopenedclosed

Closed by request.

comment:5 Changed 11 years ago by lakin.wecker@…

So, my friend re-installed python from a binary and it seemed to clear up this issue for us.

comment:6 Changed 11 years ago by lakin.wecker@…

And apparently the python binary was 2.5.2, and he was running 2.5.1 when the problems were occuring.

comment:7 Changed 10 years ago by mpcabd

Resolution: invalid
Status: closedreopened
Version: SVN1.0

I'm currently using Python 2.6 with Django 1.0 with MySQL 6.0.4 on a Windows XP and having the same problem.
I know I shouldn't use Windows but I'm developing on it now for a short period of time. :)

comment:8 Changed 10 years ago by Russell Keith-Magee

Resolution: worksforme
Status: reopenedclosed

The original report was caused by a messed up Python install. If you're seeing "the same problem", then you also have a messed up Python install, and there's not much we can do. If you're seeing the same error message, it may not be the same cause, in which case you should open a new ticket with a complete set of instructions for reproducing the problem.

Note: See TracTickets for help on using tickets.
Back to Top