#25600: Template `if` tag behavior change with 1.8, OneToOneField, RelatedObjectDoesNotExist is True? ---------------------------------+-------------------- Reporter: syphar | Owner: nobody Type: Bug | Status: new Component: Template system | Version: 1.8 Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ---------------------------------+-------------------- We discovered a strange behavior change when upgrading from Django 1.7 to 1.8.
Let's assume we have a {{{OneToOneField}}} like here: {{{#!python class Customer(models.Model): name = models.CharField(max_length=100) class Project(models.Model): customer = models.OneToOneField(Customer) title = models.CharField(max_length=100) }}} the template gets the {{{Customer}}} instance, without a project, in the context. {{{ {% if customer.project %} {# on 1.8 we get here #} {% else %} {# on 1.7 we get here #} {% endif %} }}} when debugging and trying to access {{{customer.project}}} in a django shell, we get a {{{RelatedObjectDoesNotExist}}} in both versions, so this does not seem to have changed. So to us it looks like the behavior of the {{{if}}} tag in templates changed. I'm happy to provide more info as needed, or test stuff. Or even write a PR / Fix if someone points me to possible places where this could have been changed / broken. -- Ticket URL: <https://code.djangoproject.com/ticket/25600> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/049.e2956f25768ddf785e69812a970556f7%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.