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

Fails on reverse oneToOne relationship #94

Open
jasonfarkas opened this issue Dec 9, 2022 · 2 comments
Open

Fails on reverse oneToOne relationship #94

jasonfarkas opened this issue Dec 9, 2022 · 2 comments

Comments

@jasonfarkas
Copy link

I have s.t like

class ModelA(SoftDeleteModel): 
   ...

class ModelB(SoftDeleteModel):
  model_a = models.OneToOneField(to=ModelA, on_delete=models.SET_NULL)

when I attempt to delete an instance of model a from the admin. It fails saying 'ModelA' object has no attribute '.all()'
this is b/c it is hitting this line

getattr(self, rel).all().update(**{x.remote_field.name: None})

instead of realizing that it is a reverse oneToOne field.

@lidorkook
Copy link

Similar issue for me, trying to delete instance of model a, it throws RelatedObjectDoesNotExist: A has no b, because I don't have any ModelB instance pointing to the deleted model a instance.

@decibyte
Copy link
Contributor

@lidorkook your issue is not the same as the one @jasonfarkas has reported. I believe your problem has been solved, but the fix is not yet released to PyPI. Did you try installing directly from GitHub in order to see if the problem is still there?

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

3 participants