I have a Django model that has a foreign key for another model:
class Example(models.Model)
something = models.ForeignKey(SomeModel, db_index=True)
I want to save the base column of the database as a field, but to get rid of the foreign key constraint in the database.
So, the model will change to:
class Example(models.Model):
something_id = models.IntegerField()
And, to be clear, something_idthis is the column created by Django for the foreign key field.
I don’t want to drop the column and recreate it (this is what Django does when I automatically generate the migration after changing the model as above).
I want to keep the field, but I want to remove the foreign key constraint in the wrap database. I don’t understand how to do this with Django porting - is there any built-in support for it or do I need to run some raw SQL, and if so, how can I programmatically get the name of the constraint?
source
share