useful_inkleby.useful_django.models package


useful_inkleby.useful_django.models.flexi module

FlexiModel tidies up adding up methods to models and querysets.

class useful_inkleby.useful_django.models.flexi.ApplyManagerMethodMeta[source]

Bases: django.db.models.base.ModelBase

Customise the metaclass to apply a decorator that allows custom manager and queryset methods

class useful_inkleby.useful_django.models.flexi.CustomRootManager[source]

Bases: django.db.models.manager.Manager

get_or_none(*args, **kwargs)[source]
class useful_inkleby.useful_django.models.flexi.FlexiModel(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Class for models to inherit to receive correct metaclass that allows the floating decorators

use instead of models.Model

class Meta[source]
abstract = False

Decorator for models that allows functions to be transposed to querysets and managers can decorate models directly - or make a subclass of FlexiModel.


Decorator for a model method to make it a manager method instead.

will be accessible as

“self” will then be the manager object.

self.model - can then be used to access model. self.get_queryset() - to get access to a query


Decorator for a model method to make it apply to the queryset.

Will be accessible as model.objects.all().foo()

“self” will then be the query object.

useful_inkleby.useful_django.models.mixins module

class useful_inkleby.useful_django.models.mixins.EasyBulkModel(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Bulk Creation Mixin

Mixin to help with creation of large numbers of models with streamlined syntax.

class Meta[source]
abstract = False

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.


A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

classmethod EasyBulkModel.init_queue()[source]

Add current object to the class creation queue

classmethod EasyBulkModel.queue_length()[source]
classmethod EasyBulkModel.save_queue(safe_creation_rate=1000, retrieve=True)[source]

Saves all objects stored in the class queue in batches.

If retrieve = true (default) will return a list of the saved objects.

classmethod EasyBulkModel.save_queue_if_count(count=1000)[source]
class useful_inkleby.useful_django.models.mixins.StockModelHelpers[source]

Bases: object

common functions useful for all models - diagnostics etc

Module contents

class useful_inkleby.useful_django.models.FlexiBulkModel(*args, **kwargs)[source]

Bases: useful_inkleby.useful_django.models.flexi.FlexiModel, useful_inkleby.useful_django.models.mixins.EasyBulkModel, useful_inkleby.useful_django.models.mixins.StockModelHelpers

class Meta[source]
abstract = False