Domanda

Amo Django ma ottenere file statici serviti nello sviluppo è dolorosamente più sfilato.Ho installato webasset per rendere il lavoro più facile.Fondamentalmente, i miei beni sono 404'ing con la mia configurazione attuale ma le attività di amministrazione sono belle (?!).Il mio layout del mio progetto è come questo;

myapp/
    common/
        static/
            bootstrap/
                img/
                less/
                js/
        templates/
        __init__.py
        assets.py
        urls.py
        models.py
        views.py
    projects/
        templates/
        static/
        __init__.py
        assets.py
        urls.py
        models.py
        views.py
    public/ <- (static files collected here)
settings.py
.

Nelle mie impostazioni ho configurato i seguenti valori

__DIR__ = os.path.abspath(os.path.dirname(__file__))
MEDIA_ROOT = os.path.join(__DIR__, 'media')
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(__DIR__, 'public')
STATIC_URL = '/static/'
.

I miei URL sono configurati come questo;

urlpatterns = patterns('',
    url(r'^projects/', include('myapp.projects.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', include('myapp.common.urls')),
)

urlpatterns += staticfiles_urlpatterns()
.

ancora, assets.py sembra piuttosto standard;

from django_assets import register, Bundle

js = Bundle(
    'bootstrap/js/bootstrap-alert.js',
    'bootstrap/js/bootstrap-button.js',
    'bootstrap/js/bootstrap-carousel.js',
    'bootstrap/js/bootstrap-collapse.js',
    'bootstrap/js/bootstrap-modal.js',
    'bootstrap/js/bootstrap-popover.js',
    'bootstrap/js/bootstrap-scrollspy.js',
    'bootstrap/js/bootstrap-tab.js',
    'bootstrap/js/bootstrap-tooltip.js',
    'bootstrap/js/bootstrap-transition.js',
    'bootstrap/js/bootstrap-typeahead.js',
    output='bootstrap/script.js',
    debug=False
)

register('js', js)
.

e il mio modello di base è molto semplice;

{% load assets %}
{% assets 'js' %}
    <script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}
.

Allora, quando il runserver è in esecuzione, tutti i file JS sono in bundle in 1 tag con il seguente URL http://localhost:8000/static/bootstrap/script.js?ed501ad2.Ma questo 404 con il messaggio "'bootstrap / script.js' non è stato trovato".

Se tuttavia, accedo l'app / admin, tutte le risorse CSS sono rese correttamente correttamente.Ho eseguito collezionisti e verificata che le risorse vivono effettivamente all'interno della directory public/.

Cosa mi manca qui?

È stato utile?

Soluzione

Hai aggiunto django_assets.finders.AssetsFinder al tuo STATICFILES_FINDERS come richiesto nel documento di Django-Asset?

http://elsdoerfer.name/docs/webassets/django/index.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top