utils.timezone.make_aware()

make_aware(value, timezone=None, is_dst=None) [source] Returns an aware datetime that represents the same point in time as value in timezone, value being a naive datetime. If timezone is set to None, it defaults to the current time zone. When pytz is installed, the exception pytz.AmbiguousTimeError will be raised if you try to make value aware during a DST transition where the same time occurs twice (when reverting from DST). Setting is_dst to True or False will avoid the exception by choosi

utils.functional.cached_property

class cached_property(object, name) [source] The @cached_property decorator caches the result of a method with a single self argument as a property. The cached result will persist as long as the instance does, so if the instance is passed around and the function subsequently invoked, the cached result will be returned. Consider a typical case, where a view might need to call a model’s method to perform some computation, before placing the model instance into the context, where the template m

core.files.uploadhandler.FileUploadHandler.handle_raw_input()

FileUploadHandler.handle_raw_input(input_data, META, content_length, boundary, encoding) [source] Allows the handler to completely override the parsing of the raw HTTP input. input_data is a file-like object that supports read()-ing. META is the same object as request.META. content_length is the length of the data in input_data. Don’t read more than content_length bytes from input_data. boundary is the MIME boundary for this request. encoding is the encoding of the request. Return None if yo

views.generic.dates.DateDetailView

class DateDetailView [source] A page representing an individual object. If the object has a date value in the future, the view will throw a 404 error by default, unless you set allow_future to True. Ancestors (MRO) django.views.generic.detail.SingleObjectTemplateResponseMixin django.views.generic.base.TemplateResponseMixin django.views.generic.dates.BaseDateDetailView django.views.generic.dates.YearMixin django.views.generic.dates.MonthMixin django.views.generic.dates.DayMixin django.views.g

admin.ModelAdmin.save_model()

ModelAdmin.save_model(request, obj, form, change) [source] The save_model method is given the HttpRequest, a model instance, a ModelForm instance and a boolean value based on whether it is adding or changing the object. Here you can do any pre- or post-save operations. For example to attach request.user to the object prior to saving: from django.contrib import admin class ArticleAdmin(admin.ModelAdmin): def save_model(self, request, obj, form, change): obj.user = request.user

db.models.Variance

class Variance(expression, sample=False, **extra) [source] Returns the variance of the data in the provided expression. Default alias: <field>__variance Return type: float Has one optional argument: sample By default, Variance returns the population variance. However, if sample=True, the return value will be the sample variance. SQLite SQLite doesn’t provide Variance out of the box. An implementation is available as an extension module for SQLite. Consult the SQlite document

gis.geos.GEOSGeometry.geom_typeid

GEOSGeometry.geom_typeid Returns the GEOS geometry type identification number. The following table shows the value for each geometry type: Geometry ID Point 0 LineString 1 LinearRing 2 Polygon 3 MultiPoint 4 MultiLineString 5 MultiPolygon 6 GeometryCollection 7

test.runner.DiscoverRunner

class DiscoverRunner(pattern='test*.py', top_level=None, verbosity=1, interactive=True, failfast=False, keepdb=False, reverse=False, debug_sql=False, **kwargs) DiscoverRunner will search for tests in any file matching pattern. top_level can be used to specify the directory containing your top-level Python modules. Usually Django can figure this out automatically, so it’s not necessary to specify this option. If specified, it should generally be the directory containing your manage.py file. v

test.override_settings()

override_settings() [source] In case you want to override a setting for a test method, Django provides the override_settings() decorator (see PEP 318). It’s used like this: from django.test import TestCase, override_settings class LoginTestCase(TestCase): @override_settings(LOGIN_URL='/other/login/') def test_login(self): response = self.client.get('/sekrit/') self.assertRedirects(response, '/other/login/?next=/sekrit/') The decorator can also be applied to TestCas

core.mail.get_connection()

get_connection(backend=None, fail_silently=False, *args, **kwargs) [source] By default, a call to get_connection() will return an instance of the email backend specified in EMAIL_BACKEND. If you specify the backend argument, an instance of that backend will be instantiated. The fail_silently argument controls how the backend should handle errors. If fail_silently is True, exceptions during the email sending process will be silently ignored. All other arguments are passed directly to the cons