implementing user authentication to django app which uses mongodb in backend - python

I am creating django app,
I am using
django 1.10
mongodb in backend.
To connect with mongodb I am using mongoengine 0.11 and pymongo 3.4
when I try to import User from mongoengine.django.auth, it is giving error as-
from mongoengine.django.auth import User
ImportError: No module named django.auth
can anyone help me to implement authentication using mongoengine. Some posts suggest that I should use mongoengine 0.9 but I am afraid to downgrade version as we are using mongoengine 0.11 on production and there is lot of code already written using it.
Can you please suggest me solution which does not involve changing version of above mentioned packages. Whereas I can use any other stable packages as long as existing functionality doesn't break. Or is there any way to implement authentication using django's custom authentication classes, and use relational database only for authentication.

Django by default doesn't provide any support for NoSQL database. mongoengine is python package to connect with MongoDB so it doesn't provide any direct support for authentication.Check this website if you can find any mongo backend for django https://github.com/django-nonrel.

Related

Can Django, Google App Engine and Postgres work together?

I'm trying to transfer an Openshift-hosted Django website to Google App Engine. I wanted to connect it to an existing PostgreSQL database. However, I found this in Google's documentation:
A small percentage of native C python modules, and subsets of native C python modules are not available with Google App Engine. The disabled modules fall in to the following categories: (...)
Please keep in mind that third party packages which use any of the above features will not function with Google App Engine (packages such as PostgreSQL, etc).
My local GAE server produced the following error:
ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2._psycopg
Further research seems to indicate that this error was raised due to the limitations of GAE, rather than due to a configuration error. Surely there must be some reasonable way to connect my Django website with the externally hosted PostgreSQL server. What are my options?
Edit: so to clarify, I think I need a pure-Python replacement for psycopg2 that works with Django. In other words, it should also implement a Django database backend I can use.
You might be able to use pg8000.

What versions of Django does the Django MongoDB Engine support?

Is the maintenance and support for Django MongoDB Engine still active? I searched online and found that the original author of Django MongoDB Engine already quit the project. I am wondering if it supports Django 1.8. If not, I would switch to another mongo ORM such as mongoengine.
Related question (with no answers): configuration of django_mongodb_engine with django 1.8 or any other way to use MongoDB
Django-mongodb-engine is no longer keeping up with the latest Django improvements As a web developer you can take up the challenge of connecting Django to MongoDB in several ways, but depending on what strategy you chose you may run out support from the authors sooner or later. There are several reasons for that. Listed below are some:
Use a MongoDB compatible model framework: Use a third party framework like MongoEngine or Ming in your django projects. However will miss out on:
1500+ core contributors to the project,
Hourly fixes and ticket resolution,
Ramp down on the expertise of existing Django models and ramp up on the new model framework.
Perhaps the biggest drawback is that your project can’t use any of Django’s contrib models! Forget about using Admin, Sessions, Users, Auth, etc., contrib modules for your project!
Alternatively you can try:
Django SQL to MongoDB connector — Djongo: The strategy is to translate Django SQL query syntax generated by the Django ORM into pymongo commands. Djongo is a SQL to MongoDB query compiler. It translates every SQL query string into a mongoDB query document.
SQL syntax will never change regardless of future additions to Django, by using a connector instead of a different ORM, your project will work on all versions of Django.

Difference among Mongoengine, flask-MongoEngine and Django-MongoEngine?

What are the differences between the Mongoengine, flask-MongoEngine and Django-MongoEngine projects?
I am using Mongoengine in my Django project. Will I get any benefits if I use Django-MongoEngine instead?
Django MongoEngine aim is to provide better integration with Django - however currently (June 2014) its not stable and the readme says
DO NOT CLONE UNTIL STABLE
So beware!
In addition to the other answers, flask mongoengine adds support for wtforms. If your not using flask admin, or doing server side rendering, chances are you don't need flask-mongoengine. You can just go with mongoengine
flask-mongoengine adds a few helpers to integrate MongoEngine into a Flask application.
Connection definition in Flask parameters
get_or_404 / first_or_404 shortcuts (abort 404 if document not found)
paginator added to QuerySet object
automatic form generation using WTForms
django support was pulled off Mongoengine into a separate code (django-mongoengine). Although it has no release, it seems to be worked on (see the recent commits).
Django framework provides a unified unified interface to connect to a Database backend which is usually an SQL based database such as SQLite or Postgresql. That means that the developer does not have to worry about writing code specific to the database technology used, but defines Models and perform transactions and run all kinds of queries using the Django database interface. Flask does the same.
Django does not support MongoDB from the get-go. To interact with MongoDB databases, Collections and Documents using Python one would use the PyMongo package, that has a different syntax, and paradigms than Django Models or Flask's.
MongoEngine wraps PyMongo in way that provides a Django-like Database for MongoDB.
MongoEngine-Django tries to allow Django web-apps developers to use a Mongo database as the web-app backend. To provide the Django Admin, Users, Authentication and other database related features that are available in Django usually with an SQL backend.
MongoEngine-Flash tries to allow Flask web-apps developers to use a Mongo database as the web-app backend.
Personally, I prefer using a structured SQL database for the web-app essentials, and PyMongo, or MongoEngine to interface with any further Mongo Databases where unstructured big data might reside...

How Apache Solr works with Django 1.5?

I am new on Django framework. So please help me work with solr and Django.
I am trying with some tutorial available on different site but all worked with older versions of Django and Apache Solr those are not compatible with new versions.
Django and Apache Solr have no relation with each other.
You can use django like you would use normally, and use pysolr or sunburnt python module to fetch/write data to SOLR.
I would recommend pysolr for its simplicity.

Django and multiple databases

My current Django setup uses MySQL as the main database to store models. Now for my project I need to connect to a remote PostgreSQL database and retrieve data from it. Is it possible to do this by using built-in Django and Python features or I will need to use library such as Psycopg2?
It would be great for me, if I will be able to use the Object-relational mapper of Django for this remote database.
Any ideas would be more than welcome.
Django Project is working on Multiple Database Support. There is also a recent (Nov 10 2009) blog post about "The state of MultiDB (in Django)".
Update: Multiple Databases is supported since Django v1.2 (release May 2010).

Categories