get next value for pk
Not coleifer, but I would have to say probably not. To prevent race conditions, the only reliable way to know the next id is to have it assigned to you by the DBMS, and each DBMS handles passing that information back in a different way after an ID is assigned.

https://github.com/coleifer/peewee/blob/master/peewee.py#L3389
https://github.com/coleifer/peewee/blob/master/peewee.py#L3418
https://github.com/coleifer/peewee/blob/master/peewee.py#L3132

Maybe your app is going to be single threaded forever? If so, and you're also running on Postgres you could copy and modify the Postgres implementation of last_insert_id and switch curval for nextval.
 Thanks @jakedt for the quick answer, probably I'll not change my code — it runs very rarely.
I thought I can run postgres function `nextval` for sequence and get the next id guaranteed.
It's not a problem to save the object twice for me.

I use nginx+uwsgi with four processes. Anyway — modify the Postgres implementation is too expensive :smiley: 
 I thought for some reason calling `nextval()` would increment the counter, at any rate @jakedt is correct that it's dicey to try and predict.

Is there an easy way to get the next value for the primary key (ID) of a sequence?
Needs to use id in one field of model.

I have to save the object twice now.

``` python
    def save(self, *args, **kwargs):
        rows = super().save(*args, **kwargs)
        self.code = '.'.join((self.branch.code, self.type, str(self.id)))
        return super().save(only=[Dep.code])
```
