Skip to content

Commit

Permalink
geiq: switch to OneToOneField
Browse files Browse the repository at this point in the history
To avoid warning:

    geiq.ImplementationAssessment.activity_report_file: (fields.W342)
    Setting unique=True on a ForeignKey has the same effect as using a
    OneToOneField.
        HINT: ForeignKey(unique=True) is usually better served by a
        OneToOneField.
  • Loading branch information
xavfernandez committed Jul 4, 2024
1 parent a3b23b6 commit 272f543
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions itou/geiq/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,11 @@ class Migration(migrations.Migration):
("review_comment", models.TextField(blank=True, verbose_name="commentaire")),
(
"activity_report_file",
models.ForeignKey(
models.OneToOneField(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
to="files.file",
unique=True,
verbose_name="document de synthèse",
),
),
Expand Down
3 changes: 1 addition & 2 deletions itou/geiq/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ class ImplementationAssessment(models.Model):

other_data = models.JSONField(verbose_name="autres données")

activity_report_file = models.ForeignKey(
activity_report_file = models.OneToOneField(
File,
verbose_name="document de synthèse",
null=True,
blank=True,
unique=True,
on_delete=models.PROTECT,
)

Expand Down

0 comments on commit 272f543

Please sign in to comment.