title: Django import code from other apps
body: <p>I have a project whith multiple apps. 
  So when I want some code from another app I use </p>
  
  <pre><code>from app.pyfile import *
  </code></pre>
  
  <p>or</p>
  
  <pre><code>from app.pyfile import specific_function
  </code></pre>
  
  <p>To be more specific: 
  I have an app called 'commonapp' where I have some common stuff that I use in all the other apps. In this app I have a common.py file where I have some functions, including a function called <code>my_response(request,template,context)</code> ,which is the one causes a <strong>NameError</strong>. Now this particular function is always being called inside other functions. </p>
  
  <p>for example:</p>
  
  <pre><code>from commonapp.common import *
  
  def myInfo(request):
      context = {}
      data = ''
      data =  SomeModel.objects.all()
      template = 'path/to/info.html'
      context['data'] = data
      a = my_response(request,template,context)
      return a
  </code></pre>
  
  <p>This raises a <strong>NameError "global name my_response is not defined"</strong></p>
  
  <p>I know what a NameError is, but why here? I would expect an ImportError if something could not be imported or even "global name a is not defined" .</p>
  
  <p>What am I missing here?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Here is a screenshot showing where the <code>my_response(request,template,context)</code> is and the file structure of the app. </p>
  
  <p><a href="https://i.stack.imgur.com/uR52k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uR52k.png" alt="enter image description here"></a></p>