I'm trying to learn how I can pass a table variable name through a function. So for example lets say I have a model like below
Bio(models.Model):
name = models.CharField(max_length=200)
address = models.CharField(max_length=200)
country = models.CharField(max_length=200)
now I want to be able to pass the table name through the function. So normally I would do a
people = Bio.objects.all()
for x in people:
print x.name
I want to be able to pass the "name" variable through the function something like this...
def print_name(variable):
people = Bio.objects.all()
for x in people:
print x.variable
print_name(name)
I'm not sure exactly what I should be looking into. Thanks.