1

IntegrityError: Problem installing fixture '/fixtures/orders.yaml': Could not load customers.Customer(pk=56195): column user_id is not unique

Here is my model

class Customer(UserenaBaseProfile):
    user = models.OneToOneField (User, unique=True)

I have generated the fixtures by using django fixture command and run the testcases , When running by using below command

./manage.py test orders.tests.FixturesTestFixturesTest

I am getting below error ,

Creating test database for alias 'default'...
*************
(<Customer: AnonymousUser>, True)
****************
Checking permissions: (['Can view profile', 'Can change profile', 'Can delete profile'], [], [])
*************
(<Customer: jeffrey.gulan>, True)
****************
Checking permissions: ([], [<User: jeffrey.gulan>, <User: jeffrey.gulan>, <User: jeffrey.gulan>, <User: jeffrey.gulan>, <User: jeffrey.gulan>], [])
E
======================================================================
ERROR: setUpClass (orders.tests.FixturesTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Desktop/env_app/local/lib/python2.7/site-packages/django/test/testcases.py", line 952, in setUpClass
    'database': db_name,
  File "/Desktop/env_app/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 120, in call_command
    return command.execute(*args, **defaults)
return self.cursor.execute(sql, params)
  File "/Desktop/env_app/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 318, in execute
    return Database.Cursor.execute(self, query, params)

IntegrityError: Problem installing fixture  
    '/Desktop/env_app/projectname/apps/orders/fixtures/orders.yaml':
    Could not load customers.Customer(pk=56195): column user_id is not unique

I have tried with below links also,

column user_id is not unique, with Django UserProfiles

Problems with column user_id is not unique

But I didn't get proper solution.

Would be really nice if I could get some Help!! Thanks in advance

Community
  • 1
  • 1

0 Answers0