def newroom(): form = NewRoom() if form.validate_on_submit(): image = _compat.to_bytes(form.image.name) #Turn string into binary(bytes) to be able to save it in the database rtype = rooms(category=form.category.data, quantity=form.quantity.data, beds=form.beds.data, available=form.quantity.data, price=form.price.data, facilities=form.facilities.data, image=image) db.session.add(rtype) db.session.commit() flash("Your Room has been Successfully Booked", 'success') return redirect(url_for('rdirect')) return render_template("room_category.html", title="Add RoomType", form=form)
def read(self): if self.read_bytes: return to_bytes(self.data) return self.data