Tags: jpetazzo/django
Tags
Handle Static and Media Assets We still lack the CSS required to make our admin interface look nice. We need to do three things here. First, we will edit ``settings.py`` to specify ``STATIC_ROOT``, ``STATIC_URL``, ``MEDIA_ROOT``, and ``MEDIA_URL``. Note that we decided to put those files in ``/home/dotcloud/data``. By convention, the ``data`` directory will persist across pushes. This is important: while you could store static assets in ``/home/dotcloud/current`` (or one of its subdirectories), you probably don't want to store media (user uploaded files...) in ``current`` or ``code``, because those directories are wiped out at each push. The next step is to instruct Nginx to map ``/static`` and ``/media`` to those directories in ``/home/dotcloud/data``. This is done through a Nginx configuration snippet. You can do many interesting things with custom Nginx configuration files; http://docs.dotcloud.com/guides/nginx/ gives some details about that. The last step is to add the ``collectstatic`` management command to our ``postinstall`` script. Before calling it, we create the required directories, just in case. .. After pushing this last round of modifications, the CSS for the admin site (and other static assets) will be found correctly, and we have a very basic (but functional) Django project to build on!