Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for basic mongoengine integration with Django #22

Open
foxx opened this issue Jun 20, 2014 · 7 comments
Open

Support for basic mongoengine integration with Django #22

foxx opened this issue Jun 20, 2014 · 7 comments

Comments

@foxx
Copy link

foxx commented Jun 20, 2014

Not sure if this helps but, I've made a simple django-mongoengine which can support handling Mongoengine connections via the Django connection manager, and adds setup/teardown unit test support when using mongo databases.

There is some nasty monkeypatching to make this work, but so far it seems to work pretty well out of the box. Although it doesn't add support for admin panels or anything, it works great for those that just want to use a mongodb connection in Django without any fuss.

Happy to do a better PR if you feel it's worthy enough for inclusion.

@garrypolley
Copy link

Thanks for the suggestion @foxx

Have you looked into making https://github.com/MongoEngine/django-mongoengine/tree/master better support Django + Mongo?

@foxx
Copy link
Author

foxx commented Jun 20, 2014

I'd had a look a few months ago, but wasn't keen on the approach used, and ended up making my own lightweight version as linked.

For example, handling setup/teardown of unittest data is done inside MongoTestCase, but this isn't the best way of doing things. It requires the user to inherit their unit test directly from that class, which is an unclean pattern. It would be slightly better if it worked as a mix-in, which would most likely need to contain some nasty MRO magic, but even then it still wouldn't be a great approach, for much the same reasons.

This also requires you to use MONGODB_DATABASES rather than just specifying the database inside DATABASES with a mongoengine engine string, which again feels unclean.

Both of these features could probably be merged without too much problem, although it would require a lot of testing as monkey patching could cause some weird edge cases. These changes would, naturally, be backwards incompatible for most people too.

I'm not sure if it would break the other elements such as forms/admin, I personally have no use for them as all my use cases for Mongo involve multi layer documents. The forms abstraction for Django is just not designed well for deep document resources, even with the support of EmbeddedFormField (in my own opinion), but this is a design fault with Django, not django-mongoengine.

@argoyal
Copy link

argoyal commented Sep 9, 2015

@foxx : We can use https://github.com/hspandher/django-test-addons which provides the setup and teardown functionality after run of each test case.

I also have concern here, How are we running the test cases here? I am trying to use pytest, will it be usable?

@qwiglydee
Copy link

So far, @foxx killed his repository.
Is the functionality merged into this project?

@foxx
Copy link
Author

foxx commented Nov 2, 2015

I have since stopped using Django, as I now consider it broken by design. The repo itself was killed because of backwards incompatible changes after the last Django release. I can dig out the code from archive if needed, but it's probably better to do it again from scratch.

@qwiglydee
Copy link

@foxx your blog post "42 awesome tools for programmers" does not mention django in section "Things to avoid". Wouldn't you write something about why django is broken and what do you use instead?

@foxx
Copy link
Author

foxx commented Nov 11, 2015

@qwiglydee I've got something coming out soon that tackles this very topic, stay tuned :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants