'module' object is not subscriptable
<p>here is very simplified version of my code , so pleas ignore syntax errors </p>

<p>i have a helper function basically reading a row from database using django orm and doing some validation finally return it using a dictionary </p>

<p>modVerify.py</p>

<pre><code>def verify(request):
    try :
        req = Request.objects.get(id=request.POST.get('id'))
    except :
        return({'stat':'er' , 'error':-12})

    return({'stat':'ok' , 'req':req})
</code></pre>

<p>here is where i get the error when im trying to use this above app </p>

<pre><code>  import modVerify.view
  def verify(request):

    result = modVerify.views.verify(request )

    if(result['status'] == 'ok'):
        req = modeVerify['req']
    else : 
        print('ERROR !')
</code></pre>

<p>here is my error </p>

<pre><code>TypeError at /api/verify

'module' object is not subscriptable

Request Method:     POST
Request URL:    site.com/api/verify
Django Version:     1.9.7
Exception Type:     TypeError
Exception Value:    

'module' object is not subscriptable

Exception Location:     /home/somedomain/project/api/views.py in verify, line 98
Python Executable:  /usr/local/bin/python3
Python Version:     3.4.4
</code></pre>

<p>which points to this line</p>

<pre><code> req = modeVerify['req']
</code></pre>

<p>so why im getting this and is there a way around it or should i return row <code>id</code>  back instead and read it again from database in the caller function ? </p>

<p>It seems like you should be doing </p>

<pre><code>req = result['req']
</code></pre>

<p>instead of </p>

<pre><code>req = modeVerify['req']
</code></pre>

python django