Skip to content

Two admin views for the same table/model #961

Description

@mmzeynalli

Checklist

  • There are no similar issues or pull requests for this yet.

Is your feature related to a problem? Please describe.

So, I have Vacancy table:

from enum import Enum
from sqlalchemy.orm import DeclarativeBase

class VacancyStatus(str, Enum):
    DRAFT = 'draft'
    ACTIVE = 'active'
    INACTIVE = 'inactive'
    ARCHIVED = 'archived'
    DELETED = 'deleted'
    PAUSED = 'paused'
    EXPIRED = 'expired'
    CLOSED = 'closed'

class Vacancy(DeclarativeBase):
    __tablename__ = 'company_vacancy'
    id: Mapped[int]
    status: Mapped[VacancyStatus] = mapped_column(String, default=VacancyStatus.ACTIVE)

I have many unverified draft vacancies, which are later processed one by one. As they are many, I want to have two views in admin: Vacancy and DraftVacancy. I planned to separate with overriding list_query function, however, as it is the same class, I get the same identity, so URL is the same for both views.

Describe the solution you would like.

Enable to indicate identity as parameter. If not given, use slugify_class_name(obj.__class__.__name__).

Describe alternatives you considered

I had to create another class to bypass.

class DraftVacancy(Vacancy):
    pass

And use a new view for this "new" class"

Additional context

SQLAdmin: v0.21.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions