I am building a UI for a java application in django. I want to create Java tables according to the ones created by JPA. For this when i use the ManyToMany Field, the newly created intermediate table has column names which are not matching the ones with the JPA.
Is there any way that i can give custom names to the columns in the table So, as to not get the Missing column error in Java.
Any help would be really appreciated.
You can specify a custom through
model without specifying any extra fields. Then you can use db_column=...
in the ForeignKey
fields:
class A(models.Model):
...
class B(models.Model):
a = models.ManyToManyField(A, through='C', db_table='customtablename')
class C(models.Model):
a = models.ForeignKey(A, db_column='customcolumnname')
b = models.ForeignKey(B, db_column='secondcustomcolumnname')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With