I am trying to get all fields to display but im only getting a few of my fields. I am unsure why so here is my views
my view imports
def switchingowners(request):
ownersofcar = Owner.objects.filter(CarID = request.user['CarID'])
for owner in ownersofcar :
addingOwner = models.Owner(CarID=form['CarID'],Owner_Date=ownerofcar['Owner_Date']
)
ok my models look like
class Owner(models.Model):
carID = models.ForeignKey(Car)
Owner_Entry_Number = models.IntegerField()
Owner_Date = models.DateField('Proprietor start date', null=True, blank=True)
Owner_Last_Name = models.CharField(max_length=50, null=True, blank=True)
Owner_First_Name = models.CharField(max_length=50, null=True, blank=True)
Owner_Middle_Initial = models.CharField(max_length=6, null=True, blank=True)
Owner_Address = models.CharField(max_length=80, null=True, blank=True)
my database backend has information in all fields
ownersofcar = Owner.objects.filter(CarID = request.user['CarID'])
it tells me TypeError and the filtered objects i see are
self
[<Owner: 1248612 MALCOLM DESRIVIERES >, <Owner: 1248612 JULIETTA REMY >, <Owner: 1248B612 THERESA DESIR >, <Owner: 1248B612 ALEXANDER JEAN>]
where on earth are the other fields? i dont see any documentation on secifying which fields i want to receive cause i want them all!
each field has important information im basically switching all the names from one car to another car/ multiple cars
but filter is not giving back all the fields
I assume you are getting a type error because you are doing request.user['CarId']
. Unless you using a custom user class this is not valid.
The fields are all there, what you see is just a string representation of your result as defined by the __str__
or __unicode__
method of Owner
.
Either change this method or print the field that you want, e.g.:
for owner in ownersofcar:
logger.error(owner.Owner_Address)