Hello,

Some background first. I am working with a legacy database that is not
only legacy, it is legacy Microsoft access so there is some hacking
going on. I am accessing a MySQL backend and my models are set up to
use the existing tables/field names. When I use regular old ORM
queries, Everything works as normal and I can access fields using a
for loop and iterator.fieldname.

In order to access the joined fields between two tables, I had to
resort to the manager.raw syntax. Here is my syntax

confirm_data = Checkin.objects.raw('SELECT * FROM Checkin JOIN
CheckinTests ON Checkin.SampleID = CheckinTests.SampleID WHERE
Checkin.DateArrived = %s AND Checkin.Company = %s', [date_arrived,
company_name])

1. I have to use the legacy db table names and field names i.e.
CamelCase names
2. Once the query is executed and either in the shell or a template,
when I iterate over the queryset for the main table I can use
c.fieldname but for the joined table I have to use c.FieldName. It's
as if the joined table isn't returning the model names but the table
names from MySQL. Is this a bug? It's kindof annoying to have to use
two different syntaxes in my templates.

Hope this makes sense, please let me know if I need to clarify.

Greg

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to