views.generic.dates.BaseDateListView.get_date_list()

get_date_list(queryset, date_type=None, ordering='ASC') [source] Returns the list of dates of type date_type for which queryset contains entries. For example, get_date_list(qs, 'year') will return the list of years for which qs has entries. If date_type isn’t provided, the result of get_date_list_period() is used. date_type and ordering are simply passed to QuerySet.dates().

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.

forms.ModelChoiceField.empty_label

empty_label By default the <select> widget used by ModelChoiceField will have an empty choice at the top of the list. You can change the text of this label (which is "---------" by default) with the empty_label attribute, or you can disable the empty label entirely by setting empty_label to None: # A custom empty label field1 = forms.ModelChoiceField(queryset=..., empty_label="(Nothing)") # No empty label field2 = forms.ModelChoiceField(queryset=..., empty_label=None) Note that if a

db.models.expressions.Case

class Case(*cases, **extra) [source] A Case() expression is like the if ... elif ... else statement in Python. Each condition in the provided When() objects is evaluated in order, until one evaluates to a truthful value. The result expression from the matching When() object is returned. A simple example: >>> >>> from datetime import date, timedelta >>> from django.db.models import CharField, Case, Value, When >>> Client.objects.create( ... name='Jane D

db.models.SET()

SET() [source] Set the ForeignKey to the value passed to SET(), or if a callable is passed in, the result of calling it. In most cases, passing a callable will be necessary to avoid executing queries at the time your models.py is imported: from django.conf import settings from django.contrib.auth import get_user_model from django.db import models def get_sentinel_user(): return get_user_model().objects.get_or_create(username='deleted')[0] class MyModel(models.Model): user = models.

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()

test.SimpleTestCase.client

SimpleTestCase.client Every test case in a django.test.*TestCase instance has access to an instance of a Django test client. This client can be accessed as self.client. This client is recreated for each test, so you don’t have to worry about state (such as cookies) carrying over from one test to another. This means, instead of instantiating a Client in each test: import unittest from django.test import Client class SimpleTest(unittest.TestCase): def test_details(self): client =

middleware.cache.UpdateCacheMiddleware

class UpdateCacheMiddleware [source]

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

db.models.fields.related.RelatedManager.create()

create(**kwargs) Creates a new object, saves it and puts it in the related object set. Returns the newly created object: >>> b = Blog.objects.get(id=1) >>> e = b.entry_set.create( ... headline='Hello', ... body_text='Hi', ... pub_date=datetime.date(2005, 1, 1) ... ) # No need to call e.save() at this point -- it's already been saved. This is equivalent to (but much simpler than): >>> b = Blog.objects.get(id=1) >>> e = Entry( ... blog=b, .