I am having a problem using inspectdb in django for a legacy database. I believe my issue is essentially the opposite of what is described here:
Django suffix ForeignKey field with _id
Many field names in my database end with "_id". Upon running inspectdb, those fields which end in "_id" and are also ForeignKeys or OneToOneFields have the "_id" removed:
class AssayClassMap(models.Model):
ass_cls_map_id = models.BigIntegerField(primary_key=True)
assay = models.ForeignKey('Assays', models.DO_NOTHING, blank=True, null=True)
I can fix this by changing the above lines to this:
class AssayClassMap(models.Model):
ass_cls_map_id = models.BigIntegerField(primary_key=True)
assay_id = models.ForeignKey('Assays', models.DO_NOTHING, blank=True, null=True, db_column='assay_id')
The issue is that there are hundreds of these that will need to be manually changed each time the model file is generated both for this database and other databases. I can come up with a script to correct these problems but I'd like to think there is some workaround.
Thanks