Ticket #15983: static.diff
File static.diff, 3.6 KB (added by , 14 years ago) |
---|
-
.txt
old new 48 48 See the documentation for the :setting:`STATICFILES_FINDERS` setting for 49 49 details on how ``staticfiles`` finds your files. 50 50 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 60 52 :setting:`INSTALLED_APPS`. 61 53 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 74 61 easiest method is to use the included context processor which will allow 75 62 template code like: 76 63 … … 83 70 84 71 When you're ready to move out of local development and deploy your project: 85 72 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 87 78 static files collected to when you use the :djadmin:`collectstatic` 88 79 management command. For example:: 89 80 90 81 STATIC_ROOT = "/home/jacob/projects/mysite.com/sitestatic" 91 82 92 2. Run the :djadmin:`collectstatic` management command::83 3. Run the :djadmin:`collectstatic` management command:: 93 84 94 85 ./manage.py collectstatic 95 86 96 87 This'll churn through your static file storage and copy them into the 97 88 directory given by :setting:`STATIC_ROOT`. 98 89 99 3. Deploy those files by configuring your webserver of choice to serve the90 4. Deploy those files by configuring your webserver of choice to serve the 100 91 files in :setting:`STATIC_ROOT` at :setting:`STATIC_URL`. 101 92 102 93 :ref:`staticfiles-production` covers some common deployment strategies … … 306 297 # ... the rest of your URLconf goes here ... 307 298 ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 308 299 309 .. note::310 311 The helper function will only be operational in debug mode and if312 the given prefix is local (e.g. ``/static/``) and not a URL (e.g.313 ``http://static.example.com/``).314 315 300 .. _staticfiles-production: 316 301 317 302 Serving static files in production