Code Monkey home page Code Monkey logo

Comments (9)

rossdavidh avatar rossdavidh commented on July 21, 2024

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?

from django-mongoadmin.

jschrewe avatar jschrewe commented on July 21, 2024

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.

from django-mongoadmin.

rossdavidh avatar rossdavidh commented on July 21, 2024

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

  1. admin.site.register(Group, GroupAdmin)
    File "/usr/local/lib/python2.7/dist-packages/mongoadmin-0.2-py2.7.egg/mongoadmin/sites.py" in register
  2.         from mongoadmin.validation import validate
    
    File "/usr/local/lib/python2.7/dist-packages/mongoadmin-0.2-py2.7.egg/mongoadmin/validation.py" in
  3. from django.contrib.admin.validation import validate as django_validate

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!

from django-mongoadmin.

jschrewe avatar jschrewe commented on July 21, 2024

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.

from django-mongoadmin.

acron0 avatar acron0 commented on July 21, 2024

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.

from django-mongoadmin.

rossdavidh avatar rossdavidh commented on July 21, 2024

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.

from django-mongoadmin.

jschrewe avatar jschrewe commented on July 21, 2024

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 .admin. If it's not in there nothing is gonna happen.

from django-mongoadmin.

rossdavidh avatar rossdavidh commented on July 21, 2024

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? :)

from django-mongoadmin.

jschrewe avatar jschrewe commented on July 21, 2024

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).

from django-mongoadmin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.