Location of static files when creating a Django exe using pyinstaller
<p>I have a Django project with the following structure:
root
  videos
    static
    templates</p>

<p>and the STATIC_URL setting in settings.py is STATIC_URL = '/static/'</p>

<p>I managed to use pyinstaller to create a windows executable from manage.py. I can start the Django server but I can't figure out where to put the static files.</p>

<p>When I first started the server it could not find the templates as well, it searched for them in : 'root\django\contrib\admin\templates\videos\' I copied the templates to this folder and it worked. But I can't figure out where to put the static files. I tried putting them in 'root\django\contrib\admin\static' to recreate the original structure. But it seems it doesn't search for them there... </p>

<p>Anyone knows where the static files should go? Or how to define the place where a bundled pyinstaller exe will look for them ?</p>

<p>First make sure that <code>django.contrib.staticfiles</code> is included in your <code>INSTALLED_APPS</code> in <code>settings.py</code>. Then have to insert in your <code>settings.py</code> for example this one:</p>

<pre><code>STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]
</code></pre>

<p>I hope definition of <code>BASE_DIR</code> you have in the top of <code>settings.py</code>. <code>BASE_DIR</code> points to a folder, where your <code>manage.py</code> file exists. So if you would have static files in the same dir, then you leave above setting as it is. If not, let's say in the same dir, next to <code>manage.py</code> you will have folder named <code>app</code>, then your settings should look like:</p>

<pre><code>STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "app/static"),
]
</code></pre>

<p>And you can even run:</p>

<pre><code>python manage.py collectstatic
</code></pre>

<p>To get admin static files into your static directory.</p>

<p>Hope that helps.</p>

python django pyinstaller