Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
なぜこれが機能しないのですか?State.objects.filter(pk__regex=r'^[0-9]')
State.objects.filter(pk__regex=r'^[0-9]')
エラーが発生します:
指定された名前と引数の型に一致する演算子はありません
正規表現は文字列用ですが、pk は整数です。
何をしようとしているのか正確にはわかりませんが、pk が 0 から 9 のすべての状態を取得したい場合は、範囲を使用できます。
State.objects.filter(pk__range=(0, 9))