SO I created a django project and app as per the tutorial and I have all the dependencies necessarry for MongoDB Engine it all seemed to be working fine and dandy till I tried e
For some reason none of the solutions here worked for me. python ./manage.py tellsiteid
, there was no django_site
collection, and commenting out 'django.contrib.sites'
caused weird errors.
Grabbing the ID from the shell worked for me though, detailed here:
https://gist.github.com/ielshareef/2986459 or here Site matching query does not exist
python ./manage.py shell
>>> from django.contrib.sites.models import Site
>>> Site().save()
>>> Site.objects.all()[0].id
u'4fe7aa759e654e2662000000'
Put it in settings.py
and everything worked great!
If you do not need the sites
functionality (which is very probable) simply turn off django.contrib.sites
app and it will fix MongoDB issues related to the SITE_ID:
INSTALLED_APPS = (
(...)
# 'django.contrib.sites', # Comment this out
(...)
)
You haven't created any Site yet. Run manage.py syncdb
to create one.
I ran into this during my setup the other day.
Basically you need to logo into a mongo shell and lookup your siteid then add it your settings.py
log into a mongo shell
mongo
select your db
use *name*
then do a find() on django_site
db.django_site.find()
Then open your settings.py and edit the site_ID ="" line (mine is below)
SITE_ID = u'4f1f82011d41c81e5c00001d'
That should get you up and running
have you tried this: http://django-mongodb.org/troubleshooting.html#site-id-issues
Most likely you havent created a site yet, to do so you need to run the command
python manage.py syncdb
This creates the site, now you need to add its site_id in your settings file. Go get the site id, connect to mongodb engine that is running, and run the following commands
use mydatabase --/# or whatever name you have for your database.
db.django_site.find()
you will get something like
ObjectId("4f4e968adea3b3b30c00001d")
then in your settings file, put
site_id = u'4f4e968adea3b3b30c00001d'
and the admin interface should work. Does it?