Question

I'm contributing on a 3rd party Django package and trying to make it compatible with django-nonrel. The only issue really is that a model contains a ManyToManyField using "through" attribute, which is not supported by nonrel. So I want to add a condition, which only adds the field to the model if the Django framework is NOT nonrel.

How can I identify that the Django framework is nonrel? I don't necessarily want to depend on it being GAE, Mongo or some other usage. Just plain nonrel.

Was it helpful?

Solution

This is the solution, courtesy of @aburgel:

from django.db import connection
if connection.features.supports_joins:
   # sql stuff....
   pass
else:
   # NoSQL, i.e., nonrel stuff
   pass
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top