Skip to content

Handle ObjectDoesNotExist for related instances #92

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

Merged
merged 1 commit into from
Nov 7, 2018

Conversation

dsanders11
Copy link
Contributor

Currently if get_instances_from_related raises an RelatedObjectDoesNotExist exception it escapes instead of being considered related_model = None like it should. This PR fixes that.

@dsanders11 dsanders11 force-pushed the related-does-not-exist branch from 55c74c4 to a173b1c Compare April 19, 2018 23:43
@dsanders11
Copy link
Contributor Author

PR updated to handle all invocations of get_instances_from_related.

@phoebebright
Copy link

Can this request be merged? Need this fix!

@phoebebright
Copy link

phoebebright commented Jul 3, 2018

Found also need to trap Attribute error::

     except ObjectDoesNotExist:
            related = None
     except AttributeError:
            related = None

This was running es 6, django2, python 3.6.1 with::

  elasticsearch==6.3.0
  elasticsearch-dsl==6.1.0

Note that the latest version of elasticsearch-dsl is 6.2.0 but this has removed DocType in init so this library currently requires <= 6.1.0

@sabricot sabricot merged commit 9cc6022 into django-es:master Nov 7, 2018
@sabricot
Copy link
Member

sabricot commented Nov 7, 2018

Thank you @dsanders11 and sorry for the delay again :)

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

Successfully merging this pull request may close these issues.

3 participants