Ticket #15983: static.diff

File static.diff, 3.6 KB (added by Daniele Procida, 13 years ago)
  • .txt

    old new  
    4848       See the documentation for the :setting:`STATICFILES_FINDERS` setting for
    4949       details on how ``staticfiles`` finds your files.
    5050
    51     2. Set the :setting:`STATIC_URL` setting to the URL you want to use
    52        for pointing to your static files, e.g.::
    53 
    54            STATIC_URL = '/static/'
    55 
    56        In projects freshly created with the :djadmin:`startproject`
    57        management command this will be preset to ``'/static/'``.
    58 
    59     3. Make sure that ``django.contrib.staticfiles`` is in your
     51    2. Make sure that ``django.contrib.staticfiles`` is in your
    6052       :setting:`INSTALLED_APPS`.
    6153
    62        If you are using the :ref:`runserver<staticfiles-runserver>` for local
    63        development, it will automatically find and serve your static files at the
    64        :setting:`STATIC_URL` you specified in step 2.
    65        
    66        If you are using some other server for local development, you'll need to add   
    67        :ref:`staticfiles_urlpatterns<staticfiles-development>` to your URLconf.
    68        
    69        Assuming the default preset, a file in an app's ``static/`` subdirectory will be
    70        served up at '/static/'. Therefore, the file ``my_app/static/my_app/css/my_app.css``
    71        will be served up at '/static/my_app/css/my_app.css'.
    72        
    73     4. You'll probably need to refer to these files in your templates. The
     54       For :ref:`local development<staticfiles-development>`, if you are using
     55       :ref:`runserver<staticfiles-runserver>` or adding
     56       :ref:`staticfiles_urlpatterns<staticfiles-development>` to your URLconf,
     57       you're done! Your static files will automatically be served at the
     58       default :setting:`STATIC_URL` of ``/static/``.
     59
     60    3. You'll probably need to refer to these files in your templates. The
    7461       easiest method is to use the included context processor which will allow
    7562       template code like:
    7663
     
    8370
    8471When you're ready to move out of local development and deploy your project:
    8572
    86     1. Set the :setting:`STATIC_ROOT` setting to point to where you'd like your
     73    1. Set the :setting:`STATIC_URL` setting to the public URL for your static
     74       files (in some cases, the default value of ``/static/`` may still be
     75       fine).
     76
     77    2. Set the :setting:`STATIC_ROOT` setting to point to where you'd like your
    8778       static files collected to when you use the :djadmin:`collectstatic`
    8879       management command. For example::
    8980
    9081            STATIC_ROOT = "/home/jacob/projects/mysite.com/sitestatic"
    9182
    92     2. Run the :djadmin:`collectstatic` management command::
     83    3. Run the :djadmin:`collectstatic` management command::
    9384
    9485            ./manage.py collectstatic
    9586
    9687       This'll churn through your static file storage and copy them into the
    9788       directory given by :setting:`STATIC_ROOT`.
    9889
    99     3. Deploy those files by configuring your webserver of choice to serve the
     90    4. Deploy those files by configuring your webserver of choice to serve the
    10091       files in :setting:`STATIC_ROOT` at :setting:`STATIC_URL`.
    10192
    10293       :ref:`staticfiles-production` covers some common deployment strategies
     
    306297        # ... the rest of your URLconf goes here ...
    307298    ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    308299
    309 .. note::
    310 
    311     The helper function will only be operational in debug mode and if
    312     the given prefix is local (e.g. ``/static/``) and not a URL (e.g.
    313     ``http://static.example.com/``).
    314 
    315300.. _staticfiles-production:
    316301
    317302Serving static files in production
Back to Top