template.backends.base.Template.render()

Template.render(context=None, request=None) Renders this template with a given context. If context is provided, it must be a dict. If it isn’t provided, the engine will render the template with an empty context. If request is provided, it must be an HttpRequest. Then the engine must make it, as well as the CSRF token, available in the template. How this is achieved is up to each backend. Here’s an example of the search algorithm. For this example the TEMPLATES setting is: TEMPLATES = [ {

Tablespaces

A common paradigm for optimizing performance in database systems is the use of tablespaces to organize disk layout. Warning Django does not create the tablespaces for you. Please refer to your database engine’s documentation for details on creating and managing tablespaces. Declaring tablespaces for tables A tablespace can be specified for the table generated by a model by supplying the db_tablespace option inside the model’s class Meta. This option also affects tables automatically created f

syndication.views.Feed

class views.Feed This example illustrates all possible attributes and methods for a Feed class: from django.contrib.syndication.views import Feed from django.utils import feedgenerator class ExampleFeed(Feed): # FEED TYPE -- Optional. This should be a class that subclasses # django.utils.feedgenerator.SyndicationFeed. This designates # which type of feed this should be: RSS 2.0, Atom 1.0, etc. If # you don't specify feed_type, your feed will be RSS 2.0. This # should be

syndication.Feed.get_context_data()

Feed.get_context_data(**kwargs) There is also a way to pass additional information to title and description templates, if you need to supply more than the two variables mentioned before. You can provide your implementation of get_context_data method in your Feed subclass. For example: from mysite.models import Article from django.contrib.syndication.views import Feed class ArticlesFeed(Feed): title = "My articles" description_template = "feeds/articles.html" def items(self):

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

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.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.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.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.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.