utils.safestring.SafeText

class SafeText [source] A str (in Python 3) or unicode (in Python 2) subclass that has been specifically marked as “safe” for HTML output purposes.

views.generic.dates.YearMixin.get_year_format()

get_year_format() [source] Returns the strftime() format to use when parsing the year. Returns year_format by default.

utils.feedgenerator.SyndicationFeed.item_attributes()

item_attributes(item) [source] Return extra attributes to place on each item (i.e. item/entry) element.

views.generic.edit.FormMixin.get_form()

get_form(form_class=None) Instantiate an instance of form_class using get_form_kwargs(). If form_class isn’t provided get_form_class() will be used.

conf.urls.i18n.i18n_patterns()

i18n_patterns(*urls, prefix_default_language=True) [source] This function can be used in a root URLconf and Django will automatically prepend the current active language code to all URL patterns defined within i18n_patterns(). Setting prefix_default_language to False removes the prefix from the default language (LANGUAGE_CODE). This can be useful when adding translations to existing site so that the current URLs won’t change. Example URL patterns: from django.conf.urls import include, url fr

template.context_processors.static()

static() [source] If this processor is enabled, every RequestContext will contain a variable STATIC_URL, providing the value of the STATIC_URL setting.

views.generic.dates.YearMixin.get_previous_year()

get_previous_year(date) [source] Returns a date object containing the first day of the year before the date provided. This function can also return None or raise an Http404 exception, depending on the values of allow_empty and allow_future.

admin.ModelAdmin.readonly_fields

ModelAdmin.readonly_fields By default the admin shows all fields as editable. Any fields in this option (which should be a list or tuple) will display its data as-is and non-editable; they are also excluded from the ModelForm used for creating and editing. Note that when specifying ModelAdmin.fields or ModelAdmin.fieldsets the read-only fields must be present to be shown (they are ignored otherwise). If readonly_fields is used without defining explicit ordering through ModelAdmin.fields or M

admin.AdminSite.add_action()

AdminSite.add_action(action, name=None) [source] Some actions are best if they’re made available to any object in the admin site – the export action defined above would be a good candidate. You can make an action globally available using AdminSite.add_action(). For example: from django.contrib import admin admin.site.add_action(export_selected_objects) This makes the export_selected_objects action globally available as an action named “export_selected_objects”. You can explicitly give the

Managing static files (e.g. images, JavaScript, CSS)

Websites generally need to serve additional files such as images, JavaScript, or CSS. In Django, we refer to these files as “static files”. Django provides django.contrib.staticfiles to help you manage them. This page describes how you can serve these static files. Configuring static files Make sure that django.contrib.staticfiles is included in your INSTALLED_APPS. In your settings file, define STATIC_URL, for example: STATIC_URL = '/static/' In your templates, either hardcode the url lik