[Fixed]-DatabaseError: column does not exist

1👍

Since you are adding fields manually, instead of using Django’s database migrations, as noted by Shang Wang, you just need to make sure that the field names match up. In this case, take note of the exact error given by Django:

DatabaseError: column digital_publisher_rw_item.FK_Project_id does not exist

It is looking for FK_Project_id, as opposed to the FK_Project, which you added. This is because of a convention in Django, which appends _id to the end of ForeignKey columns. So, you have two options for handling this:

  1. Rename the column in the database: ALTER TABLE digital_publisher_rw_item RENAME COLUMN FK_Project TO FK_Project_id

  2. Tell Django to use the column you created: FK_Project = models.ForeignKey(Project_Master, null=True, blank=True, db_column='FK_Project')

Leave a comment