[Fixed]-Django is overwriting the existing model

1👍

The problem here is that you’ve given your AutoField a default value. You’re telling Django to assign that field the value 1 if you don’t provide it, which means that you keep writing rows with the same id.

So just get rid of that default.

The broader point to understand is that defaults are a Django-level feature, while AutoField is a database-level feature. From the perspective of the database, there’s no difference between explicitly assigned column values and Django default column values.

Leave a comment