Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6150369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:36:15+00:00 2026-05-23T19:36:15+00:00

I’ve had the admin site working for my django app before but now I

  • 0

I’ve had the admin site working for my django app before but now I just can’t find out what is the problem.

On settings.py I have the mongodb database configuration:

DATABASES = {
    'default': {
        'ENGINE': 'django_mongodb_engine', 
        'NAME': 'myapp', 
        'USER': 'username',
        'PASSWORD': '********'
        'HOST': 'myserver.com',          
        'PORT': '27157',
        'SUPPORTS_TRANSACTIONS': False,
    }
}

I know those settings are correct because I have already some views reading information from the database and displaying it. So I know for a fact that my application can connect to the mongodb database.

I’ve configured urls.py, admin.py and settings.py to enable the admin site (and I had it working at some point before). However now when I try to access it I just get:

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in wrapper
  214.                 return self.admin_view(view, cacheable)(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py" in _wrapped_view
  93.                     response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  79.         response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in inner
  195.             if not self.has_permission(request):
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in has_permission
  148.         return request.user.is_active and request.user.is_staff
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/middleware.py" in __get__
  9.             request._cached_user = get_user(request)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/__init__.py" in get_user
  107.         user_id = request.session[SESSION_KEY]
File "/usr/local/lib/python2.6/dist-packages/django/contrib/sessions/backends/base.py" in __getitem__
  47.         return self._session[key]
File "/usr/local/lib/python2.6/dist-packages/django/contrib/sessions/backends/base.py" in _get_session
  195.                 self._session_cache = self.load()
File "/usr/local/lib/python2.6/dist-packages/mongoengine/django/sessions.py" in load
  26.             s = MongoSession.objects(session_key=self.session_key,
File "/usr/local/lib/python2.6/dist-packages/mongoengine/queryset.py" in __get__
  1151.         db = _get_db()
File "/usr/local/lib/python2.6/dist-packages/mongoengine/connection.py" in _get_db
  41.         _connection[identity] = _get_connection(reconnect=reconnect)
File "/usr/local/lib/python2.6/dist-packages/mongoengine/connection.py" in _get_connection
  33.             raise ConnectionError('Cannot connect to the database')

Exception Type: ConnectionError at /admin/
Exception Value: Cannot connect to the database

I’ve introduced some debug information in the mongoengine/connection.py and I can see that the connection settings that are used to connect to the database are:

{'host': 'localhost', 'port': 27017}

which means that it is using the default connection settings instead of the settings provided by me on settings.py. Any idea of what could be causing this? Why aren’t the database settings being passed to the admin site? Maybe I forgot to do something in the admin configuration?

EDIT:
I have followed these instructions to configure my django app to work with the mongodb database. I am using djangotoolbox and django-nonrel.

Just now I realized that the mongodb engine that should be used when I set ‘ENGINE’: ‘django_mongodb_engine’ is the django-mongodb-engine and not mongoengine. But in the stacktrace I can see that it is using mongoengine. (django-mongodb-engine does not depend on mongoengine) I am guessing that the right one is being used in the views (and that’s why it works) but the admin is using mongoengine for some reason?!?!
If understand correctly my app should not even require mongoengine to work. It is only installed because I was experimenting with it some time before.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:36:15+00:00Added an answer on May 23, 2026 at 7:36 pm

    I have found the problem and I’m just posting it here to close the question.

    I had the line SESSION_ENGINE = 'mongoengine.django.sessions' somewhere in my settings.py (as a result of the evil copy/past) and that was making my application to use mongoengine instead of django-mongodb-engine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.