Home > OS >  Django: Unknown column error when running on production server
Django: Unknown column error when running on production server

Time:01-21

When I try to access my Django application on the production server (AWS EBS), it keeps returning the following error (1054, "Unknown column 'two_factor_phonedevice.throttling_failure_timestamp' in 'field list'").

Strangely, the app works fine when running locally using the exact same MYSQL database (AWS RDS) and settings. I have tried dropping the database and re-running migrations believing it was due to an inconsistency between my db and migrations files however I still keep getting the same error.

I am using the django_two_authentication module for the user authentication/logins. The table two_factor_phonedevice is created by the module to track the user devices registered for two factor authentication.

I cannot seem to solve why the column can be found when running locally but cannot be found on the production server despite both using the same database.

CodePudding user response:

I am not familiar with django_two_authentication specifically, but I would check the different settings module you are using in each environment. You may have differences in the INSTALLED_APPS or some other relevant entry.

CodePudding user response:

Turns out the module version was not specified in the production requirements.txt file meaning the newest version (which happened to have a different db schema) was installed by default causing different versions to be running locally and in production environments.

To resolve this I explicitly set the module version in the requirements.txt file to match that of the local one.

  •  Tags:  
  • Related