I've been searching but can't find anything ...
My model is,
class Departament(db.Model):
id = Column(Integer, primary_key=True)
departament = Column(String, unique=True)
depmv = relationship('Mvpordep', backref='line', lazy='select')
depfac = relationship('Bill', backref='line_fac', lazy='select')
def __init__(self, departament):
self.departament = departament
def __repr__(self):
return '{}'.format(self.departament)
and y try
departament = Departament.query.filter_by(departament='ti').first()
print(departament.id)
but it gives me the following error
AttributeError: 'NoneType' object has no attribute 'id'
When I get multiple rows and iterate it with a for loop, no problem. But if I try to do it with a for loop, the logical thing happens
for out in departament:
print(out.id)
TypeError: 'NoneType' object is not iterable
I don't understand what happens
AttributeError: type object 'Departament' has no attribute 'objects'