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

Django object creation or table insertion #1489

Open
susanodd opened this issue Feb 6, 2025 · 0 comments
Open

Django object creation or table insertion #1489

susanodd opened this issue Feb 6, 2025 · 0 comments

Comments

@susanodd
Copy link
Collaborator

susanodd commented Feb 6, 2025

ADD MORE DESCRIPTION TO CLARIFY WHAT THIS IS ABOUT
THE FOLLOWING IS A CODE SNIPPET BUT IS INSUFFICIENT

@vanlummelhuizen

        for sense_translation in old_sense.senseTranslations.all():
            # iterate over a list because the objects will be removed
            for translation in sense_translation.translations.all():
                sense_translation.translations.remove(translation)

Are these calls to remove(...) necessary here given that they concern either vanilla many-to-many relationships or a through-model have ForeignKey fields with on_delete=models.CASCADE, e.g. GlossSense?

If the removes are not necessary, could all calls to delete of individual objects, be replaced to the delete of a few querysets? Or even one queryset, if the on_delete=models.CASCADE does the rest?

Has this code actually deleted the object, or merely removed it from the table?

There is some discrepancy between accounts online of

  • creating and object using the constructor

  • inserting a row into a table

When said object is deleted, is it actually deleted or just removed from the table?

Normally, an object may not have been deleted if other objects still refer to it

Senses can be shared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant