admin.ModelAdmin.formfield_for_foreignkey()

ModelAdmin.formfield_for_foreignkey(db_field, request, **kwargs) The formfield_for_foreignkey method on a ModelAdmin allows you to override the default formfield for a foreign keys field. For example, to return a subset of objects for this foreign key field based on the user: class MyModelAdmin(admin.ModelAdmin): def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == "car": kwargs["queryset"] = Car.objects.filter(owner=request.user)

gis.geos.WKTReader

class WKTReader Example: >>> from django.contrib.gis.geos import WKTReader >>> wkt_r = WKTReader() >>> wkt_r.read('POINT(1 1)') <Point object at 0x103a88b50>

db.models.query.QuerySet.only()

only(*fields) The only() method is more or less the opposite of defer(). You call it with the fields that should not be deferred when retrieving a model. If you have a model where almost all the fields need to be deferred, using only() to specify the complementary set of fields can result in simpler code. Suppose you have a model with fields name, age and biography. The following two querysets are the same, in terms of deferred fields: Person.objects.defer("age", "biography") Person.objects.

sessions.backends.base.SessionBase.__setitem__()

__setitem__(key, value) Example: request.session['fav_color'] = 'blue'

gis.gdal.OGRGeometry.dimension

dimension Returns the number of coordinated dimensions of the geometry, i.e. 0 for points, 1 for lines, and so forth: >> polygon.dimension 2

db.models.Aggregate

class Aggregate(expression, output_field=None, **extra) [source] template A class attribute, as a format string, that describes the SQL that is generated for this aggregate. Defaults to '%(function)s( %(expressions)s )'. function A class attribute describing the aggregate function that will be generated. Specifically, the function will be interpolated as the function placeholder within template. Defaults to None. The expression argument can be the name of a field on the model, or

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

auth.backends.AllowAllUsersModelBackend

class AllowAllUsersModelBackend New in Django 1.10. Same as ModelBackend except that it doesn’t reject inactive users because user_can_authenticate() always returns True. When using this backend, you’ll likely want to customize the AuthenticationForm used by the login() view by overriding the confirm_login_allowed() method as it rejects inactive users.

middleware.cache.UpdateCacheMiddleware

class UpdateCacheMiddleware [source]

db.models.Options.managed

Options.managed Defaults to True, meaning Django will create the appropriate database tables in migrate or as part of migrations and remove them as part of a flush management command. That is, Django manages the database tables’ lifecycles. If False, no database table creation or deletion operations will be performed for this model. This is useful if the model represents an existing table or a database view that has been created by some other means. This is the only difference when managed=F