django-nonrel/django-nonrel — Issue #3: The pk value of django Site model is set by 1.
Author: bigeye
Created: 2012-01-09 13:12:00+00:00
State: open

I'm using mongodb in django with django-nonrel, djangotoolbox, mongodb-engine packages.

When trying to "python manage.py test [[app-name]]", I got the exception like below.

```python
$ python2.7 manage.py test [[app-name]]
Traceback (most recent call last):
File "manage.py", line 14, in
execute_manager(settings)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 37, in handle
failures = test_runner.run_tests(test_labels)
File "/usr/local/lib/python2.7/site-packages/django/test/simple.py", line 359, in run_tests
old_config = self.setup_databases()
File "/usr/local/lib/python2.7/site-packages/django/test/simple.py", line 296, in setup_databases
test_db_name = connection.creation.create_test_db(self.verbosity, autoclobber=not self.interactive)
File "/usr/local/lib/python2.7/site-packages/django_mongodb_engine-0.4.0-py2.7.egg/django_mongodb_engine/creation.py", line 151, in create_test_db
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults) File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 109, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/usr/local/lib/python2.7/site-packages/django/core/management/sql.py", line 190, in emit_post_sync_signal
interactive=interactive, db=db)
File "/usr/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python2.7/site-packages/django/contrib/sites/management.py", line 21, in create_default_site
s.save(using=db)
File "/usr/local/lib/python2.7/site-packages/django/contrib/sites/models.py", line 51, in save
super(Site, self).save(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 462, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 573, in save_base
result = manager._insert(values, return_id=update_pk, using=using)
File "/usr/local/lib/python2.7/site-packages/django/db/models/manager.py", line 195, in _insert
return insert_query(self.model, values, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 1438, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python2.7/site-packages/djangotoolbox/db/basecompiler.py", line 350, in execute_sql
value = self.convert_value_for_db(db_type, value)
File "/usr/local/lib/python2.7/site-packages/django_mongodb_engine-0.4.0-py2.7.egg/django_mongodb_engine/compiler.py", line 66, in wrapper
File "/usr/local/lib/python2.7/site-packages/django_mongodb_engine-0.4.0-py2.7.egg/django_mongodb_engine/compiler.py", line 302, in convert_value_for_db
bson.errors.InvalidId: AutoField (default primary key) values must be strings representing an ObjectId on MongoDB (got u'1' instead). Please make sure your SITE_ID contains a valid ObjectId string.
```

I think the code which causes the exception is in [django/contrib/sites/management.py#L20](https://github.com/django-nonrel/django-nonrel/blob/develop/django/contrib/sites/management.py#L20). The pk value should not be set by 1.

- I'm using django-nonrel development version(for using django 1.3.1) and django-mongodb-engine 0.4.0 and djangotoolbox 0.9.2.