I Have 3 models
class Room(models.Model):
house = models.ForeignKey('Property', related_name='rooms')
beds = models.IntegerField(max_length=10)
class Property(models.Model):
......
def free_places():
places = 0
for r in self.rooms:
x = r.beds - ((r.tenant).size())
places = places + x
return places
class Profile(model.Models):
room = models.ForeignKey(Room, blank=True, null=True, related_name='tenant')
First of all I would like to know if free_places method should be: free_places(self) or free_places(). I think it has some errors too but I don't know how to test it, so here it's the question how can I call the method? and is it correct the function?
I want to call it from a django template.
To try it from "./manage.py shell" what do I need?
Thanks