Forums

Strange error during initial database migration

Hello,

I have been working on a localhost copy of my Django website for a little while now, but finally decided it was time to upload it to PythonAnywhere. The site works perfectly on my localhost, but I am getting strange errors when I do the initial migrations for the new site. For example, I get this:

mysql.connector.errors.DatabaseError: 1264: Out of range value for column 'applied' at row 1

'applied' is not a field in my model, so this error has to be generated by Django making tables for its own use. I have just checked in the MySQL manager for my localhost and the field 'applied' appears to be from the table django_migrations.

Why is Django mishandling setting up tables for its own use? I have dropped and remade the database a number of times, but the errors persist. If anyone has any idea what would cause this I would appreciate your advice very much.

My website front end is still showing the Hello World page and the Admin link comes up with a page does not exist error. At this stage I am going to assume this is related to the database errors.

It turns out that the database errors were caused by running an automatic upgrade on the PythonAnywhere site to Django 1.9. After rolling back the version to 1.8, the migrations completed correctly, but I still can't access my site from the front end. I guess I will have to investigate the issue further, but if anyone has any insight on these kind of issues, I would appreciate it very much.

It turns out that the problem with the database resulted from running an upgrade of Django from 1.8 to 1.9. I had forgotten about this. After rolling my website back to Django 1.8, the database migrations ran correctly.

The reason why I could not access the website turned out to be because I had to edit the wsgi.py file, but I was editing the wrong version. The nginx localhost web server I was using keeps it in the different folder location than PythonAnyhwere's implementation. I uploaded the file from my localhost copy and edited it according to the instructions on PythonAnywhere's help system without realizing it was not being read by their server. What I really needed to do was edit the correct file by accessing it through the web tab on the control panel. Once I edited this file, the website front end began to work as expected.

Thanks for posting all that! Hopefully anyone else who hits the same problem will be able to use it.