I am working on a project with Django 1.10, Python 3.6 and PostgreSQL as a database in which I have a model called "Article" and I need to import data from CSV files. I imported my first CSV file successfully with the following fields: identifier, link and category Identification fields start from 1 to 1960, then in the next file I started the ID field from 1961, but it shows the following error:
Line number: 1961 - duplicate key value violates the unique restriction "article_article_pkey". DETAIL: Key (id) = (1961) already exists.
Even when I see an article model in the Django admin, it shows identifiers from 1-1960
Here are 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 admin.py
@admin.register(Article)
class ArticleAdmin(ImportExportModelAdmin):
resource_class = views.ArticleResource
readonly_fields = ('id',)