[Answered ]-Django 1.3 Matching query does not exist

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.

Leave a comment