title: How to get the correct path for a django script
body: <p>Here is my arborescence</p>
  <p>V1 :</p>
  <pre><code>project/
  ---AppUser/
  ------models.py, view.Py etc ...
  ---project/
  ------settings.py, manage.py etc ...
  myscript.py
  </code></pre>
  <p>here my script works perfectly :</p>
  <pre><code>import sys
  import os
  import django
  
  
  sys.path.append(&quot;../../../project&quot;)
  os.environ[&quot;DJANGO_SETTINGS_MODULE&quot;] = &quot;project.settings&quot;
  django.setup()
  
  
  from AppUser.models import Subscription
  
  
  maps = Subscription.objects.get(uuid=&quot;1234565&quot;)
  
  print(maps)
  </code></pre>
  <p>It works fine, i launch it from the root of the project ...</p>
  <p>But when i want to put my script in a script folder :</p>
  <p>V2 :</p>
  <pre><code>project/
  ---AppUser/
  ------models.py, view.py etc ...
  ---project/
  ------settings.py, manage.py etc ...
  ---script/
  ------myscript.py
  </code></pre>
  <p>Here is my script :</p>
  <pre><code>import sys
  import os
  import django
  
  
  sys.path.append(&quot;../../../../project&quot;)
  os.environ[&quot;DJANGO_SETTINGS_MODULE&quot;] = &quot;project.settings&quot;
  django.setup()
  
  
  from AppUser.models import Subscription
  
  
  maps = Subscription.objects.get(uuid=&quot;123&quot;)
  
  print(maps)
  </code></pre>
  <p>and when i am in script/
  and i do a python3 script.Py</p>
  <p>I have a :</p>
  <pre><code>Traceback (most recent call last):
    File &quot;myscript.py&quot;, line 12, in &lt;module&gt;
      from AppUser.models import Subscription
  ModuleNotFoundError: No module named 'AppUser'
  </code></pre>
  <p>error</p>
  <p>How to be in script and not having this error ?</p>
  <p>The django.setup() seems to works fine, but after it seems to have a problem.</p>