0

I am trying to switch from the default Django user model to a custom user model. when I try to migrate the changes I get the error:

Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong.

I am using driver 13 from pyodbc. The migration works if I fake it, but throws the above error when I try to actually run the migration.

class OUser(AbstractBaseUser):
    """
    Our custom user model which may be extended later.
    """
    email = models.EmailField(verbose_name='email address', max_length=255, unique=True)
    username = models.CharField(max_length=150, unique=True)
    is_active = models.BooleanField(default=True)
    is_staff = models.BooleanField(default=False)
    is_superuser = models.BooleanField(default=False) # a superuser
    first_name = models.CharField(max_length=100, blank=True, default='')
    last_name = models.CharField(max_length=100, blank=True, default='')
    date_joined = models.DateField(auto_now=True)
    password = models.CharField(max_length=100)

    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = [] # Email & Password are required by default.

    def __str__(self):
        return self.username

    @property
    def is_staff(self):
        """Is the user a member of staff?"""
        return self.is_staff

    @property
    def is_admin(self):
        return self.is_superuser


    @property
    def is_active(self):
        return self.is_active

    objects = UserManager()

I have no Idea what this error could be from. Does anybody have any idea?

Andrea
  • 11,801
  • 17
  • 65
  • 72
wmoskal
  • 295
  • 1
  • 4
  • 15
  • 1
    So a few things: (1) I've cleaned up your code above into several sections. Have a look. (2) Migrating to a custom user model is incredibly difficult if you have started with Django's internal user, due to entity relationships. Would it be possible to start with a new Django project entirely, with a custom user model? (3) Please include the full stack trace of the error, and what versions of Django, pyodbc, and django-pyodbc (or django-pyodbc-azure) you are using. Thanks! – FlipperPA Oct 31 '19 at 18:27
  • 1
    Also, which driver are you using? I'm assuming when you say Driver 13 from pyodbc, you mean the Microsoft ODBC Driver for Linux version 13, which pyodbc will use, but is actually from Microsoft. – FlipperPA Oct 31 '19 at 18:29
  • 1
    Thanks for commenting and cleaning up the code, I actually got got this working/found a workaround since I posted – wmoskal Oct 31 '19 at 18:47
  • Good work! You can answer your own question and fill in the details... it might help someone else down the road! – FlipperPA Nov 01 '19 at 02:18

0 Answers0