sites.requests.RequestSite.__init__()

__init__(request) Sets the name and domain attributes to the value of get_host().

sites.shortcuts.get_current_site()

shortcuts.get_current_site(request) A function that checks if django.contrib.sites is installed and returns either the current Site object or a RequestSite object based on the request. It looks up the current site based on request.get_host() if the SITE_ID setting is not defined. Both a domain and a port may be returned by request.get_host() when the Host header has a port explicitly specified, e.g. example.com:80. In such cases, if the lookup fails because the host does not match a record i

staticfiles.storage.CachedStaticFilesStorage

class storage.CachedStaticFilesStorage CachedStaticFilesStorage is a similar class like the ManifestStaticFilesStorage class but uses Django’s caching framework for storing the hashed names of processed files instead of a static manifest file called staticfiles.json. This is mostly useful for situations in which you don’t have access to the file system. If you want to override certain options of the cache backend the storage uses, simply specify a custom entry in the CACHES setting named 'st

staticfiles.storage.ManifestStaticFilesStorage

class storage.ManifestStaticFilesStorage A subclass of the StaticFilesStorage storage backend which stores the file names it handles by appending the MD5 hash of the file’s content to the filename. For example, the file css/styles.css would also be saved as css/styles.55e7cbb9ba48.css. The purpose of this storage is to keep serving the old files in case some pages still refer to those files, e.g. because they are cached by you or a 3rd party proxy server. Additionally, it’s very helpful if y

staticfiles.storage.ManifestStaticFilesStorage.file_hash()

storage.ManifestStaticFilesStorage.file_hash(name, content=None) The method that is used when creating the hashed name of a file. Needs to return a hash for the given file name and content. By default it calculates a MD5 hash from the content’s chunks as mentioned above. Feel free to override this method to use your own hashing algorithm.

staticfiles.storage.StaticFilesStorage

class storage.StaticFilesStorage A subclass of the FileSystemStorage storage backend that uses the STATIC_ROOT setting as the base file system location and the STATIC_URL setting respectively as the base URL.

staticfiles.storage.StaticFilesStorage.post_process()

storage.StaticFilesStorage.post_process(paths, **options) This method is called by the collectstatic management command after each run and gets passed the local storages and paths of found files as a dictionary, as well as the command line options. The CachedStaticFilesStorage uses this behind the scenes to replace the paths with their hashed counterparts and update the cache appropriately.

staticfiles.testing.StaticLiveServerTestCase

class testing.StaticLiveServerTestCase This unittest TestCase subclass extends django.test.LiveServerTestCase. Just like its parent, you can use it to write tests that involve running the code under test and consuming it with testing tools through HTTP (e.g. Selenium, PhantomJS, etc.), because of which it’s needed that the static assets are also published. But given the fact that it makes use of the django.contrib.staticfiles.views.serve() view described above, it can transparently overlay a

staticfiles.urls.staticfiles_urlpatterns()

urls.staticfiles_urlpatterns() This will return the proper URL pattern for serving static files to your already defined pattern list. Use it like this: from django.contrib.staticfiles.urls import staticfiles_urlpatterns # ... the rest of your URLconf here ... urlpatterns += staticfiles_urlpatterns() This will inspect your STATIC_URL setting and wire up the view to serve static files accordingly. Don’t forget to set the STATICFILES_DIRS setting appropriately to let django.contrib.staticfil

staticfiles.views.serve()

views.serve(request, path) This view function serves static files in development. Warning This view will only work if DEBUG is True. That’s because this view is grossly inefficient and probably insecure. This is only intended for local development, and should never be used in production. Note To guess the served files’ content types, this view relies on the mimetypes module from the Python standard library, which itself relies on the underlying platform’s map files. If you find that this