Open acron0 opened 11 years ago
I have the same issue. In settings.py I'm using:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '/home/rosshartshorn/htdocs/sqlitedir/sqlite3db',
...along with:
from mongoengine import *
DBNAME = 'gogoworld'
CONNECTION = connect(DBNAME)
...and also:
AUTHENTICATION_BACKENDS = (
'mongoengine.django.auth.MongoEngineBackend',
'django.contrib.auth.backends.ModelBackend'
)
...and also:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
#'mongoengine.django.mongo_auth',
'sourcedocs',
'mongoadmin',
'django.contrib.admin',
...and then in my admin.py I'm using:
from mongoadmin import site, DocumentAdmin
from nouns.models import Noun, Person, Place, Event, Word
class NounAdmin(DocumentAdmin):
pass
site.register(Noun, NounAdmin)
class PersonAdmin(DocumentAdmin):
pass
site.register(Person,PersonAdmin)
class PlaceAdmin(DocumentAdmin):
pass
site.register(Place,PlaceAdmin)
class EventAdmin(DocumentAdmin):
pass
site.register(Event,EventAdmin)
class WordAdmin(DocumentAdmin):
pass
site.register(Word,WordAdmin)
...and I was thinking this would all allow me to login using the sqlite3 for the authentication only, then use mongoadmin for the rest of my models. It is apparent I have done something wrong. I can get to the admin site just fine, but it says "You have no permissions to edit anything".
Did you ever figure out your solution to this problem?
Nope. It works very fine for me and I can only fix things I can reproduce or have enough information about.
But this
AUTHENTICATION_BACKENDS = (
'mongoengine.django.auth.MongoEngineBackend',
'django.contrib.auth.backends.ModelBackend'
)
seems to use both auth methods and tries the mongoengine backend first I think. If your user comes from mongoengine you will probably run into permission problems. If you don't need mongoengine users there's no need to use the auth backend.
And I'm not sure if you did set the MONGOADMIN_OVERRIDE_ADMIN
option in your settings.py. If you didn't and have no normal models you will see the same message because Django didn't find anything to edit.
Thanks for your response. I removed the AUTHENTICATION_BACKENDS and turned MONGOADMIN_OVERRIDE_ADMIN back on. You are probably correct that this is the source of the "don't have permission to edit", but now I get the following error:
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/admin.py" in
Exception Type: ImportError at /admin/ Exception Value: cannot import name validate
...I am using python 2.7, Django 1.6.0.
I really appreciate your help!
Django 1.6 changed a lot in the admin and there isn't a release yet that works with Django 1.6. However the most current version here on github in the master branch should work with Django 1.6. Validation isn't there yet but that shouldn't really matter if you take a bit of care with your admin setups. It is also not as well tested but most of the test cases (which are in a simple Django app, so no automatic tests) I collected over time seem to work. I decided a a rewrite with a lot more inheritance was in order though.
So, in short: Use an installation from github and report any problems please. Just to be on the safe side here are the steps to install and use the github version:
# mongodbforms does most of the heavy lifting and handles forms
pip install --upgrade git+https://github.com/jschrewe/django-mongodbforms.git#mongodbforms
# and after run
pip install --upgrade git+https://github.com/jschrewe/django-mongoadmin.git#mongoadmin
That should give you a working version. Sorry for being late with the version update, but mongoadmin has accumulated quite a bit of (useless or badly written) junk over time which needs a bit of cleanup.
I will have another crack at this as well, with 1.6. I had to roll my own solution in the end, as could not get this working.
Well, we have progress, as now I am able to see Groups, Users, Sites (the stuff that I put into a sqlite3 db). However, I'm still not seeing the contents of the Mongo db. Does my admin.py above look correct?
It's been about a year since I set up a Django site (even non-Mongo), so it could be I'm forgetting something about how to get stuff showing in the admin site, but I thought the admin.py was enough to do it.
I really appreciate your help, jschrewe, and acron0 please let us know what happens on your end.
Probably obvious but easy to forget: Did you add your app with admins and documents to the INSTALLED_APPS?
The autodiscover works by importing every app in INSTALLED_APPS and then importing
Ha! And I am an idiot. I was so caught up in looking at the mongoadmin related parts, I forgot to put the app into the INSTALLED_APPS. My admin site now works! Thanks very much, I'm very excited that it's now working!
By the way, is your amazon wishlist still up to date? :)
Awesome! And I think I "debugged" several mongo related libs several times until I figured out that I made some simple configuration mistake. I guess it's quite an easy thing to get wrong.
And yes, the amazon list is still up to date (although I still need to read a couple books, so not a lot gets added).
I really, really want to use this.
I have a skeleton project with the following installed (on Ubuntu 12.10):
django-mongodbforms Django 1.4.3 Pymongo 2.4.1 Mongoengine 0.7.9
I'm not using Mongoengine for Auth, so I have a tiny SQLite db just to power the admin interface. After following the Usage steps, I log into /admin and just get "You don't have permission to edit anything". Obviously, none of my models are listed. If I revert back to admin.site urls it works fine (I can see Users, Sites etc) but minus the Mongoengine Documents...