Ticket #6804: hack.diff

File hack.diff, 933 bytes (added by floguy, 17 years ago)

This does special case checking to see if it's a RelatedObject and if so, doesn't raise a JoinError. This causes one test to break, and that's because I don't understand the implications of the change that was made. Maybe this hack can be expanded upon to get a real solution. (Using patch #6095)

  • django/db/models/sql/query.py

     
    2020from django.core.exceptions import FieldError
    2121from datastructures import EmptyResultSet, Empty, JoinError
    2222from constants import *
     23from django.db.models.related import RelatedObject
    2324
    2425try:
    2526    set
     
    10041005                    names = opts.get_all_field_names()
    10051006                    raise FieldError("Cannot resolve keyword %r into field. "
    10061007                            "Choices are: %s" % (name, ", ".join(names)))
    1007             if not allow_many and (m2m or not direct):
     1008            if not allow_many and (m2m or not direct) and not isinstance(field, RelatedObject):
    10081009                for alias in joins:
    10091010                    self.unref_alias(alias)
    10101011                raise JoinError(pos + 1)
Back to Top