1
votes

I have a model with the following fields

class UserProfile(models.Model):

  user = models.OneToOneField(User, unique=True, db_index=True, 
  related_name='profile')
  Email = models.EmailField(max_length=255, db_index=True, null=True)
  name = models.CharField(blank=True, max_length=255, db_index=True)

class Meta(object):
    db_table = "auth_userprofile"

in my Users panel inside the Django Adminsitration i have multiple users, when i try to acces one of them i get this following error

(1054, "Unknown column 'auth_userprofile.user_id' in 'field list'")

should i drop the table to fix this issue or there is another solution for this

1

1 Answers

0
votes

Dropping the table will require you to recreate it. And if you recreate it precisely as it is now, the issue will not be resolved.

This error: (1054, "Unknown column 'auth_userprofile.user_id' in 'field list'")

Is refering to a specified column, very likely in a SQL statement, where you claiming a table, auth_userprofile, has the column: user_id.

Or it could be a syntax error, and you are including the table name in the column name section, or actually quite a lot of possible errors come to mind.

The point is deleting the table will only help if you re-create it with altered column names. And dropping an entire table to either alter a column name in your code, or simply creating the column in the table seems a bit excessive?