2016-11-17 13 views
1

スクリプトファイル(angularJS)も含むdjangoアプリケーションをパッケージ化しようとしています。 exeを作成すると、静的ファイルを読み込めません(404エラー)。私は python manage.py collectstaticを試して、正しい場所からファイルをコピーしています。 しかし、私はexeを実行すると、そのファイルを読み込むことができません。Djangoアプリケーションのpyinstaller exeを作成するときのスクリプトファイルのロード

関連する質問がありますが、その解決策では問題が解決されませんでした。 Location of static files when creating a Django exe using pyinstaller

私のsettings.pyファイル

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 
STATIC_URL = '/res/' 
STATIC_ROOT = os.path.join(BASE_DIR, "res") 
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'Rule/res'), 
) 

マイspecファイル:

added_files = [ 
    ('Rule\\templates\\*.html','Rule\\templates'), 
    ('Rule\\migrations','Rule\\migrations'), 
    ('Rule\\res\\scripts\\*.js','Rule\\res\\scripts'), 
    ] 

テンプレートではなく、スクリプトファイルをロードするために、そのことが可能。

私はこのように私のhtmlファイル内のスクリプトファイルをロードしています:

{% block js %} 
<script src='{% static "scripts/app.js" %}' ></script> 
<script src='{% static "scripts/angular.js" %}'></script> 
<script src='{% static "scripts/angular-ui-router.js" %}'></script> 
<script src='{% static "scripts/angular-route.min.js" %}'></script> 
<script src="{% static "scripts/ui-grid.min.js" %}"></script> 

{%の末端ブロック%}

私はsomething.Thanks

答えて

0

をしないのですなら、私を助けてくださいてくださいManaging static files (e.g. images, JavaScript, CSS)

urls.pyファイルには、次のようなものを追加する必要があります。

from django.conf import settings 

from django.conf.urls.static import static 

urlpatterns = [ 
url(r'^login$', login, name='login'), 
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) 
関連する問題