Django Authentication Mongodb - django

Hi everyone
I want to use django's built in authentication with mongodb. I have looked online and they aren't really any stable and solid solutions.
Has anyone mongodb fans out there who can point out to me how this can be achieved with minimal hacking? That would be great.

You can't simply use Django built in authentication with MongoDB because MongoDB is not supported as a back-end for django.db which is an ORM for Django Authentication. However you may use 3rd modules like MongoEngine or MongoKit to overcome this problem as they all provide Authentication Module for MongoDB Django apps.
Note: The folks at MongoEngine provide an awesome open source project named Mumblr which is good to use as a starter for your Django-MongoDB project.

Related

Integration of cloudant with django

I am new to cloudantdb and django. Is there any way to integrate cloudantdb with danjgo framework. Is it possible to connect cloudant with django?
As you may be aware, Cloudant is built on Apache CouchDB, so if you can't find references for Cloudant, it's usually worth also searching for CouchDB. I don't really use Django, but a quick search throws up the following references:
http://leok.me/2013/05/02/what-you-need-to-know-couchdb-django/
https://lethain.com/an-introduction-to-using-couchdb-with-django/
http://eflorenzano.com/blog/2008/11/10/using-couchdb-django/
https://djangopackages.org/grids/g/couchdb/
Most if not all solutions on the web are very outdated.
The solution used by IBM in a capstone project on Coursera was:
Use SQLite backend in your Django app
Create Cloud Functions for communicating with Cloudant
Create REST API definitions in your Django app that utilize the Cloud Functions to communicate with Cloudant
I don't know if it's the best solution, but it works. I do feel like SQLite is redundant at this point but without it, I couldn't get the app to work.

Django 1.8 and MongoDB?

This question is already asked on StackOverflow,
The asked questions date back to 2013, Its 2015 now and Django has grown up fast.
What is the situation of using mongodb with Django 1.8 as of 2015?
Does Django support Monogodb out of the box (with db adapters)? or another distribution like django-nonrel should be used?
I don't think Django provides out of the box support for MongoDB. It is more tailored for relational databases.
One solution could be using MongoEngine.
MongoEngine is an Object-Document Mapper, written in Python for
working with MongoDB.
You need to just configure MongoEngine with Django and then it should work comfortably.
just my thoughts and somewhat subjective and opinionated but I would say it does not work very well. I quickly disbanded the idea of trying to run Django with MongoDB, since it's auth system is heavily reliant upon a relational database to work.
There are apparently ways around this, but ultimately I decided for my project it was not worth the effort just to use MongoDB.
Does Django support Monogodb out of the box (with db adapters)?
No, it does not. If you can find a django compatible engine for mongodb, then it will work perfectly.
The good news is there is such an engine, called django-mongodb-engine; the bad news is that it relies on django-nonrel which is not updated against the latest stable version of django.
So, if you must - you can use MongoDB at the expense of not having some updated django features available to you (and more importantly, any security patches).
If you want to supplement your main database with mongodb - that is, mongodb will not be your primary database, then the process is a lot easier.
So, in summary:
django 1.8 provides no out-of-the-box support for mongodb (or other non-relational databases) as the primary data store.
support is available using the third party django-nonrel package, which is behind the current django production version.
I came across a new package that does support the latest django on MongoDB: djongo
As stated above, mongoengine does not support all contrib apps of django. Especially the auth app doesn' work on mongoengine
Djongo claims to compile SQL queries into mongodb queries. So its is essentially version agnostic and works for all versions of Django.
Disclosure: I have contributed to this package by making minor bug fixes.
I know that its been three years but for those who are wondering about MongoDB and Django now should know that the situation has not changed. Mongoengine as described earlier is a good enough tool but still there are limitations. For instance when i integrated mongodb with django using mongoengine i was not able the use elastic search with my application. Furthermore with mongoDB you loose you loose Django admin and authentications functionalities. So, MongoDB with Django is still a risky choice

configuring mongoDB with Django

For few days I have been searching for a tutorial that shows how MongoDB can be used as a database with Django but resulted in nothing fruitful or clear tutorial. There have been questions regarding this in this forum most of them directed to look up for http://www.django-mongodb.org/ but I find there's something else written. Can anybody suggest me some good tutorial or pointers where I can start with.
P.S. I myself have searched a lot but couldn't find anything that tells the whole procedure.
The main options tu use MongoDB with Django are:
MongoEngine is an ORM for MongoDB with some Django Integration. This will not replace the Django ORM, but you're free not to use it.
Django MongoDB Engine provides a tighter intgration in Django by providing a MongoDB backend to the Django ORM, but requires the use of Django-nonrel, a fork of Django that adds support for non-relational databases.
The Django MongoDB Engine documentation formerly known as http://www.django-mongodb.org/ is now available at https://django-mongodb-engine.readthedocs.org/. For future reference, you can get the previous version of the site using the Internet Archive's Wayback Machine.

Do we still need django-nonrel now that GAE (allegedly) supports Django out of the box?

According to this question:
Django on Google App Engine
The easiest way to get started with GAE/Django is with the Django non-rel bundle. However now that the latest Python/GAE SDK includes a build of Django, do we still need this?
What's the best-practice for getting started wth Django on GAE right now?
Thanks
Update: It seems that Web app2 is the easiest choice for new projects.
This guest article suggests that
"App Engine does come with some Django support, but this is mainly
only the templating and views."
non-rel is still seemingly your best bet. Although I'd caution you that further development and/or maintenance may not happen according to their blog.
Normal Django's models doesn't have a backend supporting GAE's datastore. Hence you can't use Django models, and hence, Django's model forms. What you'd have to do use use models derived from GAE's python db.Model(). Instead of using Django's ModelForm class for forms, you would use google.appengine.ext.db.djangoforms. Note, that's specifically for ModelForms, other forms work fine since they're not tied to the database.
I can think of two good reasons to use Django-nonrel:
1a) you have a existing project on Django. Using Django-nonrel would be the laziest way to go. Rewriting models to GAE's models isn't too hard, but it could be a small pain, especially if
1b) you use a lot of existing Django components, and you'd have to go through all of them to update the models and forms.
2) You want to hedge your bets against GAE. Using Django-nonrel will allow you to switch over to MongoDB with very little effort, since Django-nonrel has a functioning MongoDB backend. The current Django-nonrel maintainers seem to be more interested in MongoDB.
Having worked with Django-nonrel, I've so far run into some reasons why it may be a bad choice:
1) No support for ancestor queries. There's an outstanding pull request for this though. It won't be compatible with any other DB backend though.
2) ndb is coming out, and seems like it'll have a few more benefits, that likely won't see support on Django-nonrel.
If you do use GAE's native db API, the main benefit from Django would be the form validation. Otherwise, webapp2+jinja2+gae db.Models() would provide similar functionality to Django.

Django on GAE: use_library vs Django-nonrel

I am really new to the world of App Engine development and I want to start with a test project on Django and GAE. I've done some research and found out that there are two major ways to use Django in my app on GAE.
Django-nonrel + djangoappengine
use_library() to load Django from SDK
Please tell about pros and cons of each way.
Is there anything better than django-nonrel if i will decide to distribute Django code with my project?
It's not a matter of two different ways to use Django - it's two different versions of Django. App Engine comes bundled with versions 0.96, 1.0 and 1.1 of Django, unmodified from the mainline release. Django-nonrel is a branch of Django, which adds support for App Engine for the database backend.
If you're writing a new app, and you want to use Django for the whole app, including the models, you should use Django-nonrel.
When using django-nonrel you can use all Django features (including admin, auth, models, queries). I don't have a complete list of django modules which are either not working or partly not working in app engine.
If you use the Django version via use_library you have to be careful with app engine's limitations (use their model api, their auth via google accounts and so on).