postgres.search.SearchRank

class SearchRank(vector, query, weights=None) [source] So far, we’ve just returned the results for which any match between the vector and the query are possible. It’s likely you may wish to order the results by some sort of relevancy. PostgreSQL provides a ranking function which takes into account how often the query terms appear in the document, how close together the terms are in the document, and how important the part of the document is where they occur. The better the match, the higher

db.models.Model.clean()

Model.clean() [source] This method should be used to provide custom model validation, and to modify attributes on your model if desired. For instance, you could use it to automatically provide a value for a field, or to do validation that requires access to more than a single field: import datetime from django.core.exceptions import ValidationError from django.db import models from django.utils.translation import ugettext_lazy as _ class Article(models.Model): ... def clean(self):

views.generic.base.TemplateResponseMixin.response_class

response_class The response class to be returned by render_to_response method. Default is TemplateResponse. The template and context of TemplateResponse instances can be altered later (e.g. in template response middleware). If you need custom template loading or custom context object instantiation, create a TemplateResponse subclass and assign it to response_class.

db.models.lookups.RegisterLookupMixin.get_transform()

get_transform(transform_name) Returns a Transform named transform_name. The default implementation looks recursively on all parent classes to check if any has the registered transform named transform_name, returning the first match.

views.generic.detail.SingleObjectTemplateResponseMixin.template_name_field

template_name_field The field on the current object instance that can be used to determine the name of a candidate template. If either template_name_field itself or the value of the template_name_field on the current object instance is None, the object will not be used for a candidate template name.

views.generic.detail.SingleObjectTemplateResponseMixin

class django.views.generic.detail.SingleObjectTemplateResponseMixin A mixin class that performs template-based response rendering for views that operate upon a single object instance. Requires that the view it is mixed with provides self.object, the object instance that the view is operating on. self.object will usually be, but is not required to be, an instance of a Django model. It may be None if the view is in the process of constructing a new instance. Extends TemplateResponseMixin Met

template.loaders.base.Loader.get_template_sources()

get_template_sources(template_name) [source] A method that takes a template_name and yields Origin instances for each possible source. For example, the filesystem loader may receive 'index.html' as a template_name argument. This method would yield origins for the full path of index.html as it appears in each template directory the loader looks at. The method doesn’t need to verify that the template exists at a given path, but it should ensure the path is valid. For instance, the filesystem l

test.SimpleTestCase.assertRaisesMessage()

SimpleTestCase.assertRaisesMessage(expected_exception, expected_message, callable, *args, **kwargs) [source] SimpleTestCase.assertRaisesMessage(expected_exception, expected_message) Asserts that execution of callable raises expected_exception and that expected_message is found in the exception’s message. Any other outcome is reported as a failure. It’s a simpler version of unittest.TestCase.assertRaisesRegex() with the difference that expected_message isn’t treated as a regular expression.

views.generic.edit.DeletionMixin

class django.views.generic.edit.DeletionMixin Enables handling of the DELETE http action. Methods and Attributes success_url The url to redirect to when the nominated object has been successfully deleted. success_url may contain dictionary string formatting, which will be interpolated against the object’s field attributes. For example, you could use success_url="/parent/{parent_id}/" to redirect to a URL composed out of the parent_id field on a model. get_success_url() Returns the u

core.validators.DecimalValidator

class DecimalValidator(max_digits, decimal_places) [source] New in Django 1.9. Raises ValidationError with the following codes: 'max_digits' if the number of digits is larger than max_digits. 'max_decimal_places' if the number of decimals is larger than decimal_places. 'max_whole_digits' if the number of whole digits is larger than the difference between max_digits and decimal_places.