core.files.storage.get_valid_name()

get_valid_name(name) Returns a filename suitable for use with the underlying storage system. The name argument passed to this method is either the original filename sent to the server or, if upload_to is a callable, the filename returned by that method after any path information is removed. Override this to customize how non-standard characters are converted to safe filenames. Changed in Django 1.9: In older versions, this method was not called when upload_to was a callable. The code provi

utils.text.slugify()

slugify(allow_unicode=False) [source] Converts to ASCII if allow_unicode is False (default). Converts spaces to hyphens. Removes characters that aren’t alphanumerics, underscores, or hyphens. Converts to lowercase. Also strips leading and trailing whitespace. For example: slugify(value) If value is "Joel is a slug", the output will be "joel-is-a-slug". You can set the allow_unicode parameter to True, if you want to allow Unicode characters: slugify(value, allow_unicode=True) If value is "你

admin.ModelAdmin.get_search_fields()

ModelAdmin.get_search_fields(request) [source] The get_search_fields method is given the HttpRequest and is expected to return the same kind of sequence type as for the search_fields attribute.

test.SimpleTestCase.client_class

SimpleTestCase.client_class If you want to use a different Client class (for example, a subclass with customized behavior), use the client_class class attribute: from django.test import TestCase, Client class MyTestClient(Client): # Specialized methods for your environment ... class MyTest(TestCase): client_class = MyTestClient def test_my_stuff(self): # Here self.client is an instance of MyTestClient... call_some_test_code()

core.files.storage._open()

_open(name, mode='rb') Required. Called by Storage.open(), this is the actual mechanism the storage class uses to open the file. This must return a File object, though in most cases, you’ll want to return some subclass here that implements logic specific to the backend storage system.

views.generic.dates.YearArchiveView.get_make_object_list()

get_make_object_list() Determine if an object list will be returned as part of the context. Returns make_object_list by default. Context In addition to the context provided by django.views.generic.list.MultipleObjectMixin (via django.views.generic.dates.BaseDateListView), the template’s context will be: date_list: A QuerySet object containing all months that have objects available according to queryset, represented as datetime.datetime objects, in ascending order. year: A date object repre

core.checks.register()

register(*tags)(function) You can pass as many tags to register as you want in order to label your check. Tagging checks is useful since it allows you to run only a certain group of checks. For example, to register a compatibility check, you would make the following call: from django.core.checks import register, Tags @register(Tags.compatibility) def my_check(app_configs, **kwargs): # ... perform compatibility checks and collect errors return errors You can register “deployment che

gis.geos.WKBWriter

class WKBWriter(dim=2) WKBWriter provides the most control over its output. By default it returns OGC-compliant WKB when its write method is called. However, it has properties that allow for the creation of EWKB, a superset of the WKB standard that includes additional information. See the WKBWriter.outdim documentation for more details about the dim argument. Changed in Django 1.10: The ability to pass the dim argument to the constructor was added. write(geom) Returns the WKB of the g

gis.geos.GEOSGeometry.simplify()

GEOSGeometry.simplify(tolerance=0.0, preserve_topology=False) Returns a new GEOSGeometry, simplified to the specified tolerance using the Douglas-Peucker algorithm. A higher tolerance value implies fewer points in the output. If no tolerance is provided, it defaults to 0. By default, this function does not preserve topology. For example, Polygon objects can be split, be collapsed into lines, or disappear. Polygon holes can be created or disappear, and lines may cross. By specifying preserve_

forms.URLField.min_length

min_length These are the same as CharField.max_length and CharField.min_length.