In views:
model = Model('some_title', 'some text')
session.add(model)
return HTTPFound(location='/ads/%s/%s' % (model.id, model.title))
So, it must redirects me to /ads/1/some_title (if id=1), instead it redirects me to /ads/None/some_title.
How to get an id of this row after created db row in this particular example?
Thanks!
at the point you ask for
model.id, the new model has not yet reached the database; pyramid waits until the request handler returns before commiting the pending transaction. To get the id earlier, you must flush the session. Add: