sitemaps.GenericSitemap

class GenericSitemap [source] The django.contrib.sitemaps.GenericSitemap class allows you to create a sitemap by passing it a dictionary which has to contain at least a queryset entry. This queryset will be used to generate the items of the sitemap. It may also have a date_field entry that specifies a date field for objects retrieved from the queryset. This will be used for the lastmod attribute in the generated sitemap. You may also pass priority and changefreq keyword arguments to the Gene

sitemaps.Sitemap.changefreq

changefreq Optional. Either a method or attribute. If it’s a method, it should take one argument – an object as returned by items() – and return that object’s change frequency as a string. If it’s an attribute, its value should be a string representing the change frequency of every object returned by items(). Possible values for changefreq, whether you use a method or attribute, are: 'always' 'hourly' 'daily' 'weekly' 'monthly' 'yearly' 'never'

sitemaps.Sitemap

class Sitemap [source] A Sitemap class can define the following methods/attributes: items [source] Required. A method that returns a list of objects. The framework doesn’t care what type of objects they are; all that matters is that these objects get passed to the location(), lastmod(), changefreq() and priority() methods. location [source] Optional. Either a method or attribute. If it’s a method, it should return the absolute path for a given object as returned by items(). If it’s

shortcuts.redirect()

redirect(to, permanent=False, *args, **kwargs) [source] Returns an HttpResponseRedirect to the appropriate URL for the arguments passed. The arguments could be: A model: the model’s get_absolute_url() function will be called. A view name, possibly with arguments: reverse() will be used to reverse-resolve the name. An absolute or relative URL, which will be used as-is for the redirect location. By default issues a temporary redirect; pass permanent=True to issue a permanent redirect.

shortcuts.get_object_or_404()

get_object_or_404(klass, *args, **kwargs) [source] Calls get() on a given model manager, but it raises Http404 instead of the model’s DoesNotExist exception.

shortcuts.render_to_response()

render_to_response(template_name, context=None, content_type=None, status=None, using=None) [source] This function preceded the introduction of render() and works similarly except that it doesn’t make the request available in the response. It’s not recommended and is likely to be deprecated in the future.

shortcuts.render()

render(request, template_name, context=None, content_type=None, status=None, using=None) [source] Combines a given template with a given context dictionary and returns an HttpResponse object with that rendered text. Django does not provide a shortcut function which returns a TemplateResponse because the constructor of TemplateResponse offers the same level of convenience as render().

shortcuts.get_list_or_404()

get_list_or_404(klass, *args, **kwargs) [source] Returns the result of filter() on a given model manager cast to a list, raising Http404 if the resulting list is empty.

Settings

Core Settings Auth Messages Sessions Sites Static Files Core Settings Topical Index Warning Be careful when you override settings, especially when the default value is a non-empty list or dictionary, such as MIDDLEWARE_CLASSES and STATICFILES_FINDERS. Make sure you keep the components required by the features of Django you wish to use. Core Settings Here’s a list of settings available in Django core and their default values. Settings provided by contrib apps are listed below, followed by a

setup()

setup(set_prefix=True) [source] Configures Django by: Loading the settings. Setting up logging. If set_prefix is True, setting the URL resolver script prefix to FORCE_SCRIPT_NAME if defined, or / otherwise. Initializing the application registry. Changed in Django 1.10: The ability to set the URL resolver script prefix is new. This function is called automatically: When running an HTTP server via Django’s WSGI support. When invoking a management command. It must be called explicitly in