Django rest-framework session timeout
<p>In a rest-api I have used <em>django rest-framework</em>. For authentication I have done:    </p>

<pre class="lang-py prettyprint-override"><code>    if username is not None and password is not None:
        user = authenticate(username=username, password=password)
        if user is not None:
            if user.is_active:
                token, created = Token.objects.get_or_create(user=user)
                if not created:
                    token.created =     datetime.datetime.utcnow().replace(tzinfo=utc)
                    token.save()
                login(request, user)
                return Response({'token': token.key, 'username': user.username})
            else:
                return Response({'status': status.HTTP_400_BAD_REQUEST})
        else:
            return Response({'status': status.HTTP_400_BAD_REQUEST})
    else:
        return Response({'status': status.HTTP_400_BAD_REQUEST})
</code></pre>

<p>And for logout:    </p>

<pre class="lang-py prettyprint-override"><code>    token = Token.objects.get(key=request.data.get('token'))
    token.delete()
    logout(request)
    return Response({'status': status.HTTP_200_OK}
</code></pre>

<p>In <em>settings.py</em> Permission classes and Authentication classes are:    </p>

<pre class="lang-py prettyprint-override"><code>    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated',
    ],

    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.TokenAuthentication',
    ],   
</code></pre>

<p>A request comes with the token included. And I have set the ideal timeout 10 minutes in angularjs.     </p>

<p>The problem is after sometime, even if its not ideal, for each requests, rest-framework responses an authentication problem. I guess, its because of the session timeout of the rest-framework.    </p>

<p>So, Can any one suggest a path to resolve this problem or, to set the default session timeout interval manually in <em>django rest-framework</em>?    </p>

<p>Thanks in advance .... </p>