Skip to content

Empty results when accessing field in chained_field. #346

Open
@YDA93

Description

@YDA93

Checklist

  • 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.
  • I have verified that that issue exists against the master branch of django-smart-selects.
  • 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.
  • 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.
  • I have used GitHub Flavored Markdown to style all of my posted code.

Steps to reproduce

class Service(models.Model):
  ...


class ServiceOption(models.Model):
    service = models.ForeignKey(
        Service,
        on_delete=models.PROTECT,
        related_name="options",
        verbose_name=_("Service"),
    )


class PartnerService(models.Model):
    service = models.ForeignKey(
        Service,
        on_delete=models.PROTECT,
        related_name="partners",
        verbose_name=_("Service"),
    )

class PartnerServiceOption(models.Model):
    service = models.ForeignKey(
        PartnerService,
        on_delete=models.PROTECT,
        related_name="options",
        verbose_name=_("Service"),
    )

    option = ChainedForeignKey(
        ServiceOption,
        chained_field="service__service",
        chained_model_field="service",
        auto_choose=True,
        on_delete=models.PROTECT,
        related_name="partners",
        verbose_name=_("Service Option"),
    )

Actual behavior

I end up with no results

Expected behavior

Should return selected_service.options.all()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions