# Path: psqlextra/models/view.py
# class PostgresMaterializedViewModel(
#     PostgresViewModel, metaclass=PostgresViewModelMeta
# ):
#     """Base class for creating a model that is a materialized view."""
# 
#     class Meta:
#         abstract = True
#         base_manager_name = "objects"
# 
#     @classmethod
#     def refresh(
#         cls, concurrently: bool = False, using: Optional[str] = None
#     ) -> None:
#         """Refreshes this materialized view.
# 
#         Arguments:
#             concurrently:
#                 Whether to tell PostgreSQL to refresh this
#                 materialized view concurrently.
# 
#             using:
#                 Optionally, the name of the database connection
#                 to use for refreshing the materialized view.
#         """
# 
#         conn_name = using or "default"
# 
#         with connections[conn_name].schema_editor() as schema_editor:
#             schema_editor.refresh_materialized_view_model(cls, concurrently)


from django.apps import apps
from django.core.management.base import BaseCommand
from django.db.utils import NotSupportedError, OperationalError
from psqlextra.models import PostgresMaterializedViewModel
        parser.add_argument(
            "app_label",
            type=str,
            help="Label of the app the materialized view model is in.",
        )

        parser.add_argument(
            "model_name",
            type=str,
            help="Name of the materialized view model to refresh.",
        )

        parser.add_argument(
            "--concurrently",
            "-c",
            action="store_true",
            help="Whether to refresh the materialized view model concurrently.",
            required=False,
            default=False,
        )

    def handle(self, *app_labels, **options):
        app_label = options.get("app_label")
        model_name = options.get("model_name")
        concurrently = options.get("concurrently")

        model = apps.get_model(app_label, model_name)
        if not model:
            raise OperationalError(f"Cannot find a model named '{model_name}'")


# Path: psqlextra/models/view.py
# class PostgresMaterializedViewModel(
#     PostgresViewModel, metaclass=PostgresViewModelMeta
# ):
#     """Base class for creating a model that is a materialized view."""
# 
#     class Meta:
#         abstract = True
#         base_manager_name = "objects"
# 
#     @classmethod
#     def refresh(
#         cls, concurrently: bool = False, using: Optional[str] = None
#     ) -> None:
#         """Refreshes this materialized view.
# 
#         Arguments:
#             concurrently:
#                 Whether to tell PostgreSQL to refresh this
#                 materialized view concurrently.
# 
#             using:
#                 Optionally, the name of the database connection
#                 to use for refreshing the materialized view.
#         """
# 
#         conn_name = using or "default"
# 
#         with connections[conn_name].schema_editor() as schema_editor:
#             schema_editor.refresh_materialized_view_model(cls, concurrently)


# Path: psqlextra/management/commands/pgrefreshmv.py
from django.apps import apps
from django.core.management.base import BaseCommand
from django.db.utils import NotSupportedError, OperationalError
from psqlextra.models import PostgresMaterializedViewModel

        parser.add_argument(
            "app_label",
            type=str,
            help="Label of the app the materialized view model is in.",
        )

        parser.add_argument(
            "model_name",
            type=str,
            help="Name of the materialized view model to refresh.",
        )

        parser.add_argument(
            "--concurrently",
            "-c",
            action="store_true",
            help="Whether to refresh the materialized view model concurrently.",
            required=False,
            default=False,
        )

    def handle(self, *app_labels, **options):
        app_label = options.get("app_label")
        model_name = options.get("model_name")
        concurrently = options.get("concurrently")

        model = apps.get_model(app_label, model_name)
        if not model:
            raise OperationalError(f"Cannot find a model named '{model_name}'")


        if not issubclass(model, PostgresMaterializedViewModel):