Skip to main content

CurrentSiteManager

Use this to limit objects to those associated with the current site.

Attributes

AttributeTypeDescription
use_in_migrationsboolean = TrueIndicates that the manager should be serialized into migrations and available on the model during migration operations.

Constructor

Signature

def CurrentSiteManager(
field_name: string = None
) - > null

Parameters

NameTypeDescription
field_namestring = NoneThe name of the Foreign Key or ManyToMany field used to associate the model with a Site.

Signature

def CurrentSiteManager(
field_name: string = null
)

Parameters

NameTypeDescription
field_namestring = nullThe name of the Foreign Key or Many-to-Many field used to associate the model with a Site.

Methods


check()

@classmethod
def check(
**kwargs: dict
) - > list

Runs system checks on the manager to ensure the specified site field exists and is of a valid type.

Parameters

NameTypeDescription
**kwargsdictAdditional keyword arguments passed to the system check framework.

Returns

TypeDescription
listA list of check error objects encountered during validation.

get_queryset()

@classmethod
def get_queryset() - > [QuerySet](../../../db/models/query/queryset.md?sid=django_db_models_query_queryset)

Returns a new QuerySet object that includes only the objects associated with the current site ID defined in settings.

Returns

TypeDescription
[QuerySet](../../../db/models/query/queryset.md?sid=django_db_models_query_queryset)A filtered QuerySet containing only records linked to the active site.