Reputation: 1823
I'm having to write a custom where clause for my query. I need to get the column name as it appears in the Oracle table from the fields in the model. I'm looping through the model fields in MyModel._meta.fields and getting the name property. In every case except one the name of the model field is the name of the column. In the exception, the field name is too long for the column, so Django's syncdb gave the column an abbreviated name. How do I get the column name?
My field name: political_contributions_description
The column name: political_contributions_de0ec3
I have tried field.get_attname_column(), as in
for field in MyModel._meta.fields:
field.get_attname_column()
But that just gives me the following tuple for my field:
('political_contributions_description', 'political_contributions_description')
Btw, an Oracle column over 30 characters will be abbreviated.
Upvotes: 0
Views: 830