geraldcor
unread,Jun 18, 2009, 6:41:30 PM6/18/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hello all,
I am trying to work with a legacy database and I ran inspectdb and
have a model with the 2 tables that I want to use. The first table,
the main table is not working at all. The second table which is
related via a foreign key seems to be working just fine. Here are the
symptoms:
In the shell I import my tables, to c=Customers.objects.all()
c
[] which is an empty dictionary or tuple (sorry for the confusion)
however if I do t=Tblcontacts.objects.all()
t
[big long list of Tblcontacts objects] and I can even utilize this
data in a template via a view.
I can't figure out why one would work while the other does not.
here are the first view field definitions in my model in case that
offers any insight.
#The customers table that doesn't work.
class Customers(models.Model):
idflcustomernum = models.AutoField(primary_key=True,
db_column='IDFLCustomerNum') # Field name made lowercase.
typenum = models.IntegerField(null=True, db_column='TypeNum',
blank=True) # Field name made lowercase.
type = models.CharField(max_length=255, db_column='Type',
blank=True) # Field name made lowercase.
billto = models.IntegerField(null=True, db_column='BillTo',
blank=True) # Field name made lowercase.
#The contacts table that works
class Tblcontacts(models.Model):
contactnumber = models.AutoField(primary_key=True,
db_column='ContactNumber') # Field name made lowercase.
clientid = models.ForeignKey(Customers, db_column='ClientID') #
Field name made lowercase.
contactname = models.CharField(max_length=50,
db_column='ContactName', blank=True) # Field name made lowercase.
title = models.CharField(max_length=50, db_column='Title',
blank=True) # Field name made lowercase.
salutation = models.CharField(max_length=50,
db_column='Salutation', blank=True) # Field name made lowercase.
Thank you for all past and future help
Greg