I have a model called snacks:
class Snack(models.Model):
snack = models.CharField(max_length=9)
When I do
Snack.objects.get_or_create(snack="borsh")
I get this error:
django.db.utils.IntegrityError: duplicate key value violates unique constraint "restaurants_snack_pkey"
DETAIL: Key (id)=(6) already exists.
If I do it again, it's going to tell me the same thing except the key (that already exists) will be 7 and so on.
It's true that the key already exists, I'm wondering how can I make it pick a key that's the next one available?
Thanks in advance.
Jenia