ImportError: Cannot import name 'DurationField'
<p>I am trying to run an application that uses django (version 1.6.5) rest framework ( python version 3.4.5 ) .However I am getting the <strong>Import error "cannot import name DurationField"</strong>.How do I resolve this error ?</p>

<pre><code>File "/usr/src/app/Lab/models.py", line 8, in &lt;module&gt;
    from Lab import logic, common &lt;br&gt;
  File "/usr/src/app/Lab/logic.py", line 16, in &lt;module&gt;
    from Rest import viewsAppComm &lt;br&gt;
  File "/usr/src/app/Rest/viewsAppComm.py", line 7, in &lt;module&gt;
    from rest_framework.response import Response &lt;br&gt;
  File "/usr/local/lib/python3.4/site-packages/rest_framework/response.py", line 13, in &lt;module&gt;
    from rest_framework.serializers import Serializer
  File "/usr/local/lib/python3.4/site-packages/rest_framework/serializers.py", line 19, in &lt;module&gt;
    from django.db.models import DurationField as ModelDurationField &lt;br&gt;
ImportError: cannot import name 'DurationField'
</code></pre>

<p><code>DurationField</code> was <a href="https://docs.djangoproject.com/en/1.8/releases/1.8/#new-data-types" rel="nofollow">added in Django 1.8</a>. You are using Django 1.6, hence the error. </p>

<p>Your options are to upgrade (which is a good idea if you can, because Django 1.6 has reached end of life quite a while ago) or to downgrade to an older version of Django Rest Framework (the version you currently have is not compatible with Django 1.6).</p>

<p>You may also be able to install the third-party <a href="https://django-durationfield.readthedocs.io/en/latest/" rel="nofollow">django-duration-field</a> app and then import it with:</p>

<pre><code>from durationfield.db.models.fields.duration import DurationField
</code></pre>

<p>... but from the stack trace you posted it looks like it is DRF that is trying to import the model.</p>

python django python-3.x django-models importerror