Hi,
I run into a strange problem when i changed my code a little and then test
my apps.In some tests(not the first) i got the error message below:

Traceback (most recent call last):
  File "D:\coding\codes\django\django\test\testcases.py", line 202, in
__call__
    self._pre_setup()
  File "D:\coding\codes\django\django\test\testcases.py", line 183, in
_pre_setu
p
    call_command('flush', verbosity=0, interactive=False)
  File "D:\coding\codes\django\django\core\management\__init__.py", line
158, in
 call_command
    return klass.execute(*args, **options)
  File "D:\coding\codes\django\django\core\management\base.py", line 222, in
exe
cute
    output = self.handle(*args, **options)
  File "D:\coding\codes\django\django\core\management\base.py", line 351, in
han
dle
    return self.handle_noargs(**options)
  File "D:\coding\codes\django\django\core\management\commands\flush.py",
line 6
0, in handle_noargs
    emit_post_sync_signal(models.get_models(), verbosity, interactive)
  File "D:\coding\codes\django\django\core\management\sql.py", line 205, in
emit
_post_sync_signal
    interactive=interactive)
  File "D:\coding\codes\django\django\dispatch\dispatcher.py", line 148, in
send

    response = receiver(signal=self, sender=sender, **named)
  File "D:\coding\codes\django\django\contrib\auth\management\__init__.py",
line
 28, in create_permissions
    defaults={'name': name, 'content_type': ctype})
  File "D:\coding\codes\django\django\db\models\manager.py", line 96, in
get_or_
create
    return self.get_query_set().get_or_create(**kwargs)
  File "D:\coding\codes\django\django\db\models\query.py", line 347, in
get_or_c
reate
    raise e
IntegrityError: (1452, 'Cannot add or update a child row: a foreign key
constrai
nt fails (`test_app_o2`.`auth_permission`, CONSTRAINT
`content_type_id_refs_id_7
28de91f` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type`
(`id`)
)')

and this is the sql i printed :
(1452, 'Cannot add or update a child row: a foreign key constraint fails (`t
est_app_o2`.`auth_permission`, CONSTRAINT `content_type_id_refs_id_728de91f`
FOR
EIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`))')
query:INSERT INTO `auth_permission` (`name`, `content_type_id`, `codename`)
VALU
ES (%s, %s, %s)  args:(u'Can add user', 3, u'add_user')

which is really wired,  as you can see the cause is: create_permissions got
called and  the content_type was not filled with data . However there are
some testcases passed, that means sometimes create_permissions works.
And then i changed the order of INSTALLED_APPS , i put
django.contrib.contenttypes before django.contrib.auth then run the test,
all my testcase passed.
But i still can't figure out why this happens, and only happens in some
testcases.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to