Error while setting up MongoDB with django using django mongodb engine on windows

2024/10/15 12:33:19

Steps I followed :

  1. 'pip install git+htp://github.com/django-nonrel/[email protected]'

It did not work, so I downloaded the zip from the site "htp://github.com/django-nonrel/django" and pasted the unzipped folder inside "c:\users\hp\appdata\local\temp\pip-m0d0y9bv-build".

  1. 'pip install git+htp://github.com/django-nonrel/djangotoolbox'
  2. 'pip install git+htp://github.com/django-nonrel/mongodb-engine'

NOTE

*** I have used 'htp' instead of 'https' as I have reputation less than 10.

  1. configured my settings.py file as follows:-

.

import os       BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))         SECRET_KEY = '4j*aieq$cn&sewl0s2#&m00+^oe%qg9p=@mlva96_r48nv-pkl'DEBUG = TrueALLOWED_HOSTS = []INSTALLED_APPS = ('django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','myapp','djangotoolbox',
)MIDDLEWARE_CLASSES = ('django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.auth.middleware.SessionAuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware','django.middleware.security.SecurityMiddleware',
)ROOT_URLCONF = 'myproject.urls'TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates','DIRS': [],'APP_DIRS': True,'OPTIONS': {'context_processors': ['django.template.context_processors.debug','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',],},},
]WSGI_APPLICATION = 'myproject.wsgi.application'DATABASES = {'default': {'ENGINE': 'django_mongodb_engine','NAME': 'test','USER': '','PASSWORD': '','HOST': 'localhost','PORT': 27017,}
}SESSION_ENGINE = 'mongoengine.django.sessions'
SESSION_SERIALIZER = 'mongoengine.django.sessions.BSONSerializer'LANGUAGE_CODE = 'en-us'TIME_ZONE = 'UTC'USE_I18N = TrueUSE_L10N = TrueUSE_TZ = TrueSTATIC_URL = '/static/'
  1. I got the below error when i started running server using command 'python manage.py runserver'

.

c:\Python34\myproject>python manage.py runserver
Traceback (most recent call last):File "manage.py", line 10, in <module>execute_from_command_line(sys.argv)File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line
338, in execute_from_command_lineutility.execute()File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line
312, in executedjango.setup()File "C:\Python34\lib\site-packages\django\__init__.py", line 18, in setupapps.populate(settings.INSTALLED_APPS)File "C:\Python34\lib\site-packages\django\apps\registry.py", line 108, in pop
ulateapp_config.import_models(all_models)File "C:\Python34\lib\site-packages\django\apps\config.py", line 198, in impor
t_modelsself.models_module = import_module(models_module_name)File "C:\Python34\lib\importlib\__init__.py", line 109, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "<frozen importlib._bootstrap>", line 2254, in _gcd_importFile "<frozen importlib._bootstrap>", line 2237, in _find_and_loadFile "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 1200, in _load_unlockedFile "<frozen importlib._bootstrap>", line 1129, in _execFile "<frozen importlib._bootstrap>", line 1471, in exec_moduleFile "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removedFile "C:\Python34\lib\site-packages\django\contrib\auth\models.py", line 41, i
n <module>class Permission(models.Model):File "C:\Python34\lib\site-packages\django\db\models\base.py", line 139, in __
new__new_class.add_to_class('_meta', Options(meta, **kwargs))File "C:\Python34\lib\site-packages\django\db\models\base.py", line 324, in ad
d_to_classvalue.contribute_to_class(cls, name)File "C:\Python34\lib\site-packages\django\db\models\options.py", line 250, incontribute_to_classself.db_table = truncate_name(self.db_table, connection.ops.max_name_length(
))File "C:\Python34\lib\site-packages\django\db\__init__.py", line 36, in __geta
ttr__return getattr(connections[DEFAULT_DB_ALIAS], item)File "C:\Python34\lib\site-packages\django\db\utils.py", line 240, in __getite
m__backend = load_backend(db['ENGINE'])File "C:\Python34\lib\site-packages\django\db\utils.py", line 111, in load_bac
kendreturn import_module('%s.base' % backend_name)File "C:\Python34\lib\importlib\__init__.py", line 109, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "<frozen importlib._bootstrap>", line 2254, in _gcd_importFile "<frozen importlib._bootstrap>", line 2237, in _find_and_loadFile "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 1200, in _load_unlockedFile "<frozen importlib._bootstrap>", line 1129, in _execFile "<frozen importlib._bootstrap>", line 1467, in exec_moduleFile "<frozen importlib._bootstrap>", line 1572, in get_codeFile "<frozen importlib._bootstrap>", line 1532, in source_to_codeFile "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removedFile "C:\Python34\lib\site-packages\django_mongodb_engine\base.py", line 272raise ImproperlyConfigured, exc_info[1], exc_info[2]^
SyntaxError: invalid syntax

What am I missing here ? I have followed the steps from django - mongoengine documentation. However, I am unable to figure out the issue. Please help me out of this.

Answer

Django-mongodb-engine does not appear to be compatible with Python 3. In any case, django-nonrel itself is based on Django 1.5, which is definitely not Python 3 compatible.

https://en.xdnf.cn/q/117834.html

Related Q&A

Python login page with pop up windows

I want to access webpages and print the source codes with python, most of them require login at first place. I have similar problem before and I have solved it with the following code, because they are…

Calculate Scipy LOGNORM.CDF() and get the same answer as MS Excel LOGNORM.DIST

I am reproducing a chart in a paper using the LOGNORM.DIST in Microsoft Excel 2013 and would like to get the same chart in Python. I am getting the correct answer in excel, but not in python.In excel …

Python MySQLdb cursor.execute() insert with varying number of values

Similar questions have been asked, but all of them - for example This One deals only with specified number of values.for example, I tried to do this the following way:def insert_values(table, columns, …

Searching in a .txt file and Comparing the two values of a string in python?

"cadence_regulatable_result": "completeRecognition","appserver_results": {"status": "success","final_response": 0,"payload": {"…

How to perform an HTTP/XML authentication with requests

I am trying to authenticate to Docushare with Python 3.4 using requests 2.7. I am relatively new to Python and to the requests module but Ive done a lot of reading and am not able to make any more prog…

webPy Sessions - Concurrent users use same session and session timeout

I have a webPy app using sessions for user authentication. Sessions are initiated like so:web.config.debug=Falsestore = web.session.DiskStore(/path_to_app/sessions) if web.config.get(_session) is None:…

get text content from p tag

I am trying to get description text content of each block on this page https://twitter.com/search?q=data%20mining&src=typd&vertical=default&f=users. html for p tag looks like<p class=&q…

Python - making a function that would add - between letters

Im trying to make a function, f(x), that would add a "-" between each letter:For example:f("James")should output as:J-a-m-e-s-I would love it if you could use simple python function…

python script keeps converting dates to utc

I have the following:import psycopg2 from openpyxl import Workbook wb = Workbook() wb.active =0 ws = wb.active ws.title = "Repair" ws.sheet_properties.tabColor = "CCFFCC"print(wb.sh…

sklearn tsne with sparse matrix

Im trying to display tsne on a very sparse matrix with precomputed distances values but Im having trouble with it.It boils down to this:row = np.array([0, 2, 2, 0, 1, 2]) col = np.array([0, 0, 1, 2, 2,…