Changes between Initial Version and Version 2 of Ticket #31310


Ignore:
Timestamp:
Feb 26, 2020, 6:33:01 PM (5 years ago)
Author:
Matheus Cunha Motta
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #31310 – Description

    initial v2  
    1 When there's more than 2 ForeignKeys pointing to the same model in an intermediary model of a m2m field and no through_fields have been set, Django will show an error with the following hint:
     1When there's more than 2 ForeignKeys in an intermediary model of a m2m field and no through_fields have been set, Django will show an error with the following hint:
    22  {{{#!python
    33hint=(
     
    55    'use ForeignKey("%s", symmetrical=False, through="%s").'
    66  }}}
    7 But to create a recursive relationship the ManyToManyField should be used instead of ForeignKey. Also symmetrical=False should only be used with m2m fields, according to model field reference (link: https://docs.djangoproject.com/en/3.0/ref/models/fields/#django.db.models.ManyToManyField.symmetrical). And more than that, setting symmetrical=False is not required for recursive relationships since Django >= 3.0.
     7But 'symmetrical' and 'through' are m2m keyword arguments, not ForeignKey.
    88
    9 This was probably a small mistake where the developer thought ManyToManyField but typed ForeignKey instead. And the symmetrical=False is an outdated requirement to recursive relationships, not applicable since 3.0. I'll provide a PR with a proposed correction shortly after.
     9This was probably a small mistake where the developer thought ManyToManyField but typed ForeignKey instead. And the symmetrical=False is an outdated requirement to recursive relationships with intermediary model to self, not required since 3.0. I'll provide a PR with a proposed correction shortly after.
     10
     11Edit: fixed description.
Back to Top