So this is a strange problem...I'm getting the Following error when try to 
view the list mode of my court_detals object in the Admin interface.


OperationalError at /admin/contrack/court_details/
(1109, "Unknown table 'contrack_locations' in order clause")
Request Method:         GET
Request URL:    http://localhost:8000/admin/contrack/court_details/
Exception Type:         OperationalError
Exception Value:        (1109, "Unknown table 'contrack_locations' in 
order clause")
Exception Location: 
/usr/lib/python2.4/site-packages/MySQLdb/connections.py in 
defaulterrorhandler, line 32

#


I think the whatever constructs the SQL interface is doing something 
wrong.. 
Below is the output of the SQL it tries to contstruct.. 
BTW,I've tried running the SQL manually, and it too tells me that it is 
wrong. 
I think that it has something to do with it leaving out the 
contrack_locations in the query it constructs. 
Also below you will find my classes for the query in question.
This is on a fresh init of the whole app (init, install admin, install 
contrack)




/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/meta/__init__.py
 
in function_get_iterator

1370. def function_get_iterator(opts, klass, **kwargs):
1371. # kwargs['select'] is a dictionary, and dictionaries' key order is
1372. # undefined, so we convert it to a list of tuples internally.
1373. kwargs['select'] = kwargs.get('select', {}).items()
1374.
1375. cursor = db.db.cursor()
1376. select, sql, params = function_get_sql_clause(opts, **kwargs)




1377. cursor.execute("SELECT " + (kwargs.get('distinct') and "DISTINCT " 
or "") + ",".join(select) + sql, params) ...

1378. fill_cache = kwargs.get('select_related')
1379. index_end = len(opts.fields)
1380. while 1:
1381. rows = cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)
1382. if not rows:
1383. raise StopIteration

â–¼ Local vars
Variable        Value
cursor 
<MySQLdb.cursors.Cursor object at 0xb6f6ca2c>
klass 
<class 'django.models.contrack.Court_detail'>
kwargs 
{'order_by': ('-contrack_locations.id',), 'select': []}
opts 
<Options for court_details>
params 
[]
select 
['`contrack_court_details`.`sector`', '`contrack_court_details`.`type`', 
'`contrack_court_details`.`district`', 
'`contrack_court_details`.`court_id`']
sql 
' FROM `contrack_court_details` ORDER BY `contrack_locations`.`id` DESC'





class Court_detail(meta.Model):
 
    sector = meta.CharField(maxlength=1, choices = SECTOR_CHOICES, 
blank=True)
    type   =  meta.CharField(maxlength=1, choices = COURT_TYPE_CHOICES)
    district = meta.CharField(maxlength=1, choices = DISTRICT_CHOICES)
    court = meta.OneToOneField(Location)

    class META:
 
        admin = meta.Admin() 




class Location(meta.Model):
    address1 = meta.CharField(maxlength=50)
    address2 = meta.CharField(maxlength=50, blank=True)
    address3 = meta.CharField(maxlength=50, blank=True)
    address4 = meta.CharField(maxlength=50, blank=True)
    city     = meta.CharField(maxlength=50)
    state    = meta.USStateField()
    zip      = meta.CharField(maxlength=10)
    type     = meta.CharField(maxlength=1, choices = LOCATION_CHOICES)

    def get_full_address(self):
        address = self.address1 + "<br>"
        for n in (self.address2, self.address3, self.address4):
            if n !="":
                address = address + n + "<br>"
        address = address + "%s, %s  %s" % (self.city, self.state, 
self.zip)
        return address
 
    def __repr__(self):
        return self.zip

    class META:
        admin = meta.Admin()

Thanks,

James


James S. Martin, RHCE
Contractor
Administrative Office of the United States Courts
Washington, DC
(202) 502-2394

Reply via email to