CurrentSiteManager
Use this to limit objects to those associated with the current site.
Attributes
| Attribute | Type | Description |
|---|---|---|
| use_in_migrations | boolean = True | Indicates 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
| Name | Type | Description |
|---|---|---|
| field_name | string = None | The name of the Foreign Key or ManyToMany field used to associate the model with a Site. |
Signature
def CurrentSiteManager(
field_name: string = null
)
Parameters
| Name | Type | Description |
|---|---|---|
| field_name | string = null | The 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
| Name | Type | Description |
|---|---|---|
| **kwargs | dict | Additional keyword arguments passed to the system check framework. |
Returns
| Type | Description |
|---|---|
list | A 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
| Type | Description |
|---|---|
[QuerySet](../../../db/models/query/queryset.md?sid=django_db_models_query_queryset) | A filtered QuerySet containing only records linked to the active site. |