Reputation: 1296
I realized that Django has Many-to-One and not One-to-Many, but how to you express the opposite relationship?
I have a table which has 2 foreign keys to another table. The table Validation_Run has 2 foreign keys to Calibration_Run Django complains that that the reverse relationship has a conflict
calibration.ValidationRun.calibration_run_pk: (fields.E304) Reverse accessor 'CalibrationRun.validationrun_set' for 'calibration.ValidationRun.calibration_run_pk' clashes with reverse accessor for 'calibration.ValidationRun.calibration_run_pk_tune_parameters'. HINT: Add or change a related_name argument to the definition for 'calibration.ValidationRun.calibration_run_pk' or 'calibration.ValidationRun.calibration_run_pk_tune_parameters'.
How do I define the reverse relationship (from Calibration_Run to Validation_Run), so there is no conflict?
Upvotes: 0
Views: 81
Reputation: 47354
You shoule specify different related_name
for these foreign key fields. Something like this:
field = models.ForeignKey(related_name="calibrations")
field2 = models.ForeignKey(related_name="calibrations2")
Upvotes: 3