django - Graphite 烯-django : 'Meta.model' without either 'Meta.fields' or 'Meta.exclude' has been deprecated since 0. 15.0 现在被禁止

标签 django graphql django-filter

我正在尝试使用 django-graphene 返回过滤结果,但它给出了关于 error-message 的错误

class PatientType(DjangoObjectType):
    class Meta:
        model = Patients
        exclude = ('active',)
        interfaces = (relay.Node,)


class PatientsQuery(ObjectType):
    get_patient = graphene.Field(PatientType, id=graphene.Int())
    all_patients = graphene.List(
        PatientType, first=graphene.Int(), skip=graphene.Int(), phone_no=graphene.Int()
    )
    upcoming_appointments = DjangoFilterConnectionField(PatientType)


@permissions_checker([IsAuthenticated, CheckIsOrganizationActive])
def resolve_upcoming_appointments(self, info, **kwargs) -> List:
    d = datetime.today() - timedelta(hours=1)
    settings.TIME_ZONE  # 'Asia/Karachi'
    aware_datetime = make_aware(d)
    res = Patients.objects.filter(appointments__booking_date__gte=aware_datetime,
                                  appointments__booking_date__day=aware_datetime.day,
                                  appointments__status=True)
    if res:
        return res
    return []


class Query(
    organization_schema.OrganizationQuery,
    inventory_schema.MedicineQuery,
    patient_schema.PatientsQuery,
    graphene.ObjectType,
):
    pass

最佳答案

filter_fields 中指定 PatientType.Meta 属性为

class PatientType(DjangoObjectType):
    class Meta:
        model = Patients
        exclude = ('active',)
        interfaces = (relay.Node,)
        filter_fields = ["field_1", "field_2"]
或者,您可以在 filter_fields=[] 部分中设置 filterset_class Meta 属性
更多示例可以在文档中找到, GraphenePython- Filtering

关于django - Graphite 烯-django : 'Meta.model' without either 'Meta.fields' or 'Meta.exclude' has been deprecated since 0. 15.0 现在被禁止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64119033/

相关文章:

postgresql - GraphQL 到 PostgresQL 类型映射

python - OR 逻辑与 Django-filter

Django比较两个对象的值

python - 如何将带有斜杠的字符串从 View 传递到模板?

python - 下载 Django 时出错

ios - Swift 中 Apollo 的自动 UI 更新不起作用

javascript - 我如何获得数组的每个用户的存储库数量?

python - 使用 django-filters 将多个过滤器合并为一个 filter()

django - 从导入的应用程序中覆盖模型的 __str__(self)

javascript - 如何在页面更新时执行jquery