2đź‘Ť
I can definitely see one problem with your models here. When you define a ForegnKey field with the name “claim_status”, Django will be automatically creating an attribute on your model instances called “claim_status_id” which will be used to store the raw value of the “claim_status” database column. However, you already have a primary key field with the same name, which probably leads to a conflict.
I am not sure what is the official way of solving this problem, but you could try to subclass ForeignKey and override its get_attname() method to return something else.
0đź‘Ť
You need to do database introspection (also called reflection), which will create the appropriate django classes for you. In django terminology, this is called inspection
Once you have got your settings.py
with the appropriate db settings, run this command:
python manage.py inspectdb > models.py
This should give you a better django mapping of your database and allow you to run your queries.
- [Answered ]-Find Sum of Columns of Data in Django Like and Excel File
- [Answered ]-<a></a> tags not being rendered when put in quotes
- [Answered ]-How to run django celery with SQS?