B
B
Boldy2014-11-10 15:04:53
Django
Boldy, 2014-11-10 15:04:53

When creating through objects.create(), an IntegrityError is thrown. How to fix?

There is a code:

o = Foo.objects.create(date=date.today())
o.save()

And model:
class Foo(models.Model):
    date = models.DateField(verbose_name='Дата создания', blank=False)

When executing the code, an error occurs:
Exception Type:	IntegrityError
Exception Value:	
UNIQUE constraint failed: foos_foos.id

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly Scherbakov, 2014-11-10
@Boldy

Looks strange. Are there any objects in table Foo ? What if we delete the table and create it again? What DBMS?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question