Re: admin interface can't find table

2006-02-10 Thread James_Martin

Sorry for the spam all, I should've check the bug tracker (#930) first...





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




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---


Re: admin interface can't find table

2006-02-10 Thread James_Martin

django-users@googlegroups.com wrote on 02/09/2006 07:20:35 PM:

> 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.
> 

snip.

To be a little less verbose, I think the SQL handler in django is not 
handling my One to One relationship correctly. 

SELECT 
`contrack_court_details`.`sector`,`contrack_court_details`.`type`,`contrack_court_details`.`district`,`contrack_court_details`.`court_id`
 
FROM `contrack_court_details` ORDER BY `contrack_locations`.`id` DESC


It _should_ be this (I constructed this by hand and it works):

SELECT 
`contrack_court_details`.`sector`,`contrack_locations`.`id`,`contrack_court_details`.`type`,`contrack_court_details`.`district`,`contrack_court_details`.`court_id`
 
FROM `contrack_court_details`, `contrack_locations` ORDER BY 
`contrack_locations`.`id` DESC


So django is leaving out the table to which OneToOneField is tied to...

Please tell me I'm doing something wrong and it's not a bug.  :)



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

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---


admin interface can't find table

2006-02-09 Thread James_Martin
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
VariableValue
cursor 

klass 

kwargs 
{'order_by': ('-contrack_locations.id',), 'select': []}
opts 

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 + ""
for n in (self.address2, self.address3, self.address4):
if n !="":
address = address + n + ""
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