Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango can't resolve attribute name
    text
    copied!<p>Can anyone see the source of this error?</p> <pre><code>django.core.exceptions.FieldError: Cannot resolve keyword 'client' into field. Choices are: auditstatushistory, file_num, invoice </code></pre> <p>The statement that is causing the problem is:</p> <pre><code>for invoice in Invoice.objects.filter(matter__client__servicer_code = "XXX"): </code></pre> <p>And the definition of Matter, which does contain file_num, and auditstatushistory and invoice as related attributes, is :</p> <pre><code>class Matter(models.Model): file_num = models.CharField(max_length=20, primary_key=True) client = models.ForeignKey("Client", db_column="client_code", related_name="client") </code></pre> <p>the only "odd" thing in here is that client did not exist as a foreign key when I set up the database originally, so I added client_code to the underlying matter table via</p> <pre><code>alter table foo_matter add client_code varchar(10) null; </code></pre> <p>And there is no foreign key in the database linking client and matter. The only thing I can think of is that I did not name the column correctly in my foo_matter table. But I can't run syncdb to try it out because South has been installed.</p> <p>UPDATE:</p> <p>Just for giggles, I tried starting with a brand-new database, commented out South, and just did a "syncdb" to see what table definitions Django would create. It created the Client and Matter tables, but did NOT create client_code (or client_id) field to store the foreign key information. </p> <p>Has anyone seen a situation like this, where Django just does not create a field? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload