Comments (8)
Thanks @lb- - on_delete
is indeed required, as per ForeignKey. Have updated the examples in the readme now.
from django-modelcluster.
I suggest we reopen this issue.
Updating large projects to Wagtail 2.0 is pretty painful only because of this. The module rename is very easy using the script, but we have to manually add the on_delete=CASCADE
attribute on each ParentalKey
.
Which brings me to this question: is there any case where we don’t want ParentalKey
to be on_delete=CASCADE
?
The whole purpose of ParentalKey
is to create models that are “contained” in a main model. When we delete a main object like a Wagtail page, we always want the data “contained” in that main object to be deleted as well. So ParentalKey
should always have CASCADE
behaviour as far as I can tell.
And therefore, what’s the point of having to manually specify it? We could force on_delete=CASCADE
on ParentalKey
s and don’t even accept any optional on_delete
argument since it wouldn’t make sense.
Side note:
When I worked on some advanced closed-source cross-models importer, I always took the assumption that on_delete=CASCADE
meant that the model is “contained” in another model. In a correctly designed database, that’s what CASCADE
means. All that to explain that not only ParentalKey
⇒ CASCADE
, but also CASCADE
⇒ ParentalKey
in a correctly designed database.
from django-modelcluster.
on_delete=models.CASCADE giving errors, requires arguments
from django-modelcluster.
TypeError: CASCADE() missing 4 required positional arguments: 'collector', 'field', 'sub_objs', and 'using'
from django-modelcluster.
@setriakorm You shouldn't put ()
after CASCADE
. If that's not the issue, please provide specific steps to reproduce this error.
from django-modelcluster.
from django-modelcluster.
I think the best way would be allowing users to set on_delete to a default value for all cases in settings.py. If not set, then it would be a required argument; if set, then use that default value for all cases.
from django-modelcluster.
@morningmorningwind I disagree... we want this package to be as useful and friendly as possible in its default configuration. on_delete=CASCADE
is the right choice for ParentalKey in every scenario we can imagine, so it makes sense for it to be the default. Moving it into a configuration option is a poor way to serve users - it means that only the users who take time to read through all the configuration options will benefit from this.
from django-modelcluster.
Related Issues (20)
- Copy fails for a Wagtail page with no tags HOT 7
- Multi table inheritance - ptr_id fields not being restored
- Using TaggedItem in ClusterTaggableManager causing AttributeError HOT 1
- Unable to `prefetch_related` on `ClusterTaggableManager` HOT 1
- When I Modify Elements via Admin Panel , Its not getting Saved HOT 1
- Add support for Django 3.2 HOT 3
- ClusterForm.as_p should return a safe string
- test suite fails with django-taggit >= 2.0.0 HOT 1
- Nested ClusterableModel relations are not copied HOT 1
- AttributeError when a ParentalKey related manager is used as the queryset for a ModelChoiceField HOT 3
- Wagtail 3.0 support planned? HOT 2
- GenericForeignKey
- Django 5.0 support HOT 1
- Filtering on related manager when using `prefetch_related` with explicit `queryset` on a ClusterableModel returns wrong results HOT 1
- Field with the same name as a lookup in `FILTER_EXPRESSION_TOKENS` causes crash when filtering with implicit `exact`
- test_formfield_callback failing with Django 4.2 HOT 1
- Docs: please provide an example of a through model with a ParentalManyToManyField
- Unhelpful messaging when model attribute name shadows child relation
- Preview breaks on latest 6.2 version HOT 3
- BaseChildFormSet doesn't caught IntegrityError for unique together using UniqueConstraint
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-modelcluster.