I'm working on a project with Django 1.10, Python 3.6 and PostgreSQL as the database backend, in which I have a model called 'Article" and I need to import data from CSV files. I have imported my first CSV file successfully with the following fields: id, link & category It's ID fields starts from 1 to 1960 then in next file, I have started ID field from 1961 to onward but it shows the following error:
Line number: 1961 - duplicate key value violates unique constraint "article_article_pkey" DETAIL: Key (id)=(1961) already exists.
Even when i see my Article model in Django admin it shows IDs from 1- 1960
Here's my models.py:
class Article(models.Model):
id = models.AutoField(primary_key=True)
link = models.URLField(max_length=255)
category = models.CharField(max_length=255, choices=Categories)
Here's admin.py
@admin.register(Article)
class ArticleAdmin(ImportExportModelAdmin):
resource_class = views.ArticleResource
readonly_fields = ('id',)