How to modify deprecated imports for a reusable app?
<p>My project depends on an OSS reusable app, and that app includes a Django import which is deprecated in Django 1.10:</p>

<p><code>from django.db.models.sql.aggregates import Aggregate</code></p>

<p>is changing to:</p>

<p><code>from django.db.models.aggregates import Aggregate</code></p>

<p>We get a warning on Django 1.9, which will become an error on Django 1.10. This is blocking our upgrade, and I want to contribute a fix to the app so we can upgrade.</p>

<p>One option would be to modify the requirements in setup.py so that Django 1.10 is required. But I'm sure my contribution would be rejected since it would break for everyone else. </p>

<p>To maintain backwards compatibility, I can do the import as a <code>try/except</code> but that feels hacky. It seems like I need to do some Django version checking in the imports.  Should I do a Django version check, which returns a string, convert that to a float, and do an <code>if version &gt; x</code>? That feels hacky too. </p>

<p>What's the best practice on this? Examples?</p>

<p>Django has a strict backwards compatibility policy. If it's raising a deprecation warning, then the new version <em>works already</em> in 1.9. You should just switch to it before you upgrade.</p>

python django