I am trying to apply a filter on a Django model based on a column name
That column is a Foreign Key
Code -
Inside models.py -
class History(models.Model):
testcaseidstring = models.ForeignKey('Testcaseidstructure', models.DO_NOTHING, db_column='testCaseIdString')
Inside views.py -
sessid_qs=History.objects.using("otherdb").filter(testcaseidstring="tc123")
This gives me the following ERROR - Field 'testcaseidstring' expected a number but got 'tc123'
How am I supposed to filter on this column?
Testcaseidstructure module:
class Testcaseidstructure(models.Model):
testcaseidstring = models.TextField(db_column='testCaseIdString')
class Meta:
managed = False
db_table = 'testCaseIdStructure'
Any help would be highly appreciable
Thanks!!