def create_photo(self,title='',caption='',image=None): """ Creates a photo directly in the database. """ with astral.app.test_request_context('/'): if image is None: image = choice(images) photo = Photo(title=title,caption=caption,image=image) photo.save() return photo