0
我有一個數據庫,其中的字段是「僞」array
。這個array
保存整數值。我的實現如下:Django檢查整數是否存在於數據庫字段數組中
attendees = models.TextField(null=True) # declaring the integer array
當我說假,我的意思是,我使用json
,使之成爲一個數組。
attendees=json.dumps(members)
現在attendees
列將包含這樣的事情["1", "2", "3"]
所以我要檢查,如果參加者將包含的值,例如「1
」。本質上,我想要這樣的事情:
eventList = Events.objects.all().filter(user_id in Event.attendees) # I know this isn't the correct syntax
有關如何儘可能有效地做到這一點的任何想法?