Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating something like a MultipleChainedForeignKey to allow multiple chained fields for a same ForeignKey Field #316

Open
luishenriquesb opened this issue Oct 7, 2020 · 0 comments

Comments

@luishenriquesb
Copy link

You MUST use this template when reporting issues. Please make sure you follow the checklist and fill in all of the information sections below.


All versions of django-smart-selects prior to version 1.2.8 are vulnerable to an XSS attack as detailed in issue 171. As a result, all previous versions have been removed from PyPI to prevent users from installing insecure versions. All users are urged to upgrade as soon as possible.

Checklist

Put an x in the bracket when you have completed each task, like this: [x]

  • [ x] This issue is not about installing previous versions of django-smart-selects older than 1.2.8. I understand that previous versions are insecure and will not receive any support whatsoever.
  • [ x ] I have verified that that issue exists against the master branch of django-smart-selects.
  • [ x ] I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • [ ] I have debugged the issue to the smart_selects app.
  • [ x ] I have reduced the issue to the simplest possible case.
  • [ ] I have included all relevant sections of models.py, forms.py, and views.py with problems.
  • [ x ] I have used GitHub Flavored Markdown to style all of my posted code.

Steps to reproduce

Actual behavior

The ChainedForeignKey allows chained just one field on the model referenced. I've already use this feature like that:

class ModeloSecao(models.Model):
    id_modelo_secao = models.AutoField(primary_key=True)
    categoria = models.ForeignKey('Categoria',
                                  on_delete=models.CASCADE)
    estruturas = models.ManyToManyField(
                                'Estrutura',)
class EstruturaSecao(models.Model):
    id_estrutura_secao = models.AutoField(primary_key=True)
    estrutura = models.ForeignKey('Estrutura',
                                  on_delete=models.CASCADE)
    categoria = models.ForeignKey('Categoria',
                                  on_delete=models.CASCADE)
    modelo_padrao = ChainedForeignKey(
                ModeloSecao,
                chained_field='categoria',
                chained_model_field='categoria',
                show_all=False,
                auto_choose=True,
                sort=True,
                on_delete=models.DO_NOTHING
             )

Expected behavior

it's would be really good if I could have a model using more than one field. I don't know how exactly this might be done. Maybe creating something like MultipleChainedForeignKey. Something like that:

class ModeloSecao(models.Model):
    id_modelo_secao = models.AutoField(primary_key=True)
    categoria = models.ForeignKey('Categoria',
                                  on_delete=models.CASCADE)
    estruturas = models.ManyToManyField(
                                'Estrutura',)
class EstruturaSecao(models.Model):
    id_estrutura_secao = models.AutoField(primary_key=True)
    estrutura = models.ForeignKey('Estrutura',
                                  on_delete=models.CASCADE)
    categoria = models.ForeignKey('Categoria',
                                  on_delete=models.CASCADE)
    modelo_padrao = MultipleChainedForeignKey(
                ModeloSecao,
                chained_fields=('categoria', 'estrutura')
                chained_model_fields=('estrutura','estruturas'),
                show_all=False,
                auto_choose=True,
                sort=True,
                on_delete=models.DO_NOTHING
             )
@luishenriquesb luishenriquesb changed the title Creating something like MultipleChainedForeignKey to allow multiple chained fields for an same ForeignKey Field Creating something like a MultipleChainedForeignKey to allow multiple chained fields for a same ForeignKey Field Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant