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
Unable to delete pages containing custom content types #323
Comments
Hi Chris Which (exact) Django and FeinCMS version are you using? The code in https://github.com/feincms/feincms/blob/master/feincms/__init__.py#L42 |
I'm using Django 1.4 and FeinCMS 1.5.4. I'll retest with 1.6.2. |
This has been plaguing me as well. It seemed at first that django-reversion was to blame but removing it did not solve the issue. It only triggers on PostgreSQL, works fine with SQLite. Probably because the latter does not check constraints... I'm trying to develop a minimal test case, with no luck so far. @chrisspen If you found a fix or workaround, do check back! |
This sounds more and more like a failure of |
This is a workaround for the problem: https://gist.github.com/4059168 It registers a pre-delete handler for your content container that will delete all attached content types. This fix could be integrated in FeinCMS, if it does not break other stuff. |
Thanks @wojas, works like a charm! |
We experienced this issue (FeinCMS@914eb0, Django 1.4.3). Our workaround is to add the following to
|
@cogat Interesting. This means that the code in https://github.com/feincms/feincms/blob/master/feincms/__init__.py#L53 does not do the right thing in this case. Now that we do not monkey-patch Does anyone have a good idea how this issue could be fixed for good? Unfortunately it has a long history already... |
A log of the calls to
the first call is from another app that uses Commenting out the lines
solves the problem, but at the expense of performance - the cache has to be repopulated once per model per request. I suggest a parameter Pull request coming... EDIT: By Django design, |
…call when a content_type is added. See feincms#323
@cogat Sounds good. As long as the performance hit only happens on application startup (whatever that is given the current state of things) that's fine. I'm still having some doubts, mainly: Does deleting the cache repeatedly really have the same consequence as calling Regarding |
* 'master' of git://github.com/ixc/feincms: Adding a 'force' parameter to ensure_completely_loaded, and a forced call when a content_type is added. See #323
Deleting the cache will cause Two things to note, however: Firstly, Secondly, Side note: calling
Yes - I mistook which cache gets cleared (I somehow thought it was [1] https://github.com/django/django/blob/master/django/db/models/options.py#L399 |
* master: Last patch re feincms#323 was a sledgehammer to crack a walnut. This is a better solution.
After trying this in a project, I have found that the patch in ixc@3ceb1a3 can cause problems in which not all reverse-related fields are registered by Django. I'm not sure of the exact cause (in a Django shell, calling |
Reverted in 5632c1c |
Alright, thanks! Can we close this issue now? |
Yes, I believe so. On 15 February 2013 19:03, Matthias Kestenholz notifications@github.comwrote:
Dr Greg Turner http://interaction.net.au Be green! Read from the screen. |
Ok, thanks! |
This patch broke my application. I have big application, where my modules located in package. So, I have validation errors like:
Maybe later I'll have time to investigate, but this patch breaks some applications for sure. |
I've been able to reproduce this with Django 1.5. Django 1.4.1 doesn't exhibit this problem. |
…ely_loaded, so as to play nice with Django 1.5.
@cogat Great! Thanks! |
* master: FeinCMS v1.7.2 Fix test_36_sitemaps Rename the _feincms_content_model class to prevent name clashes Re #399 catches "%sContent" class name conflicts and produces a warning. Better explanation re #323. Re #323 - models cache is cleared at the end of ensure_completely_loaded, so as to play nice with Django 1.5. Conflicts: feincms/__init__.py
Very nice. Thanks! |
Unfortunately this hasn't gone away; I'm using the latest FeinCMS
|
So at least ... |
…ated files The first time we only make sure that all modules are loaded; then we run through the initialization process again.
Something like that (hack alarm): |
Not sure if I understood you correctly, just I tried removing the early |
Let me try your hack commit too to confirm ;-) |
Nope, problem persists :( |
The problem seems to be that the Page model isn't actually returned by So I think you can remove your hack branch above (and I think |
Ah stupid me. This should have been Yes, using How is it even possible that |
Sounds good to me. If you want to find out more, |
…ache is ready Refs feincms#323. Thanks to Simon Meers for the report and for finding a solution.
Mind you we still have the issue of finding a way of automatically calling |
This should hopefully be sufficient... |
No, unfortunately not:
As far as I'm aware there is no |
What if you access
|
... or access |
Not See https://code.djangoproject.com/ticket/19212 for Russ' overview of the long-standing "app loading" issues in relation to this. |
Good to hear. Yes, I know about the app loading / app refactor issues. Unfortunately, the migration work also touched a lot of code in that area (app cache and everything) so a solution seems to be far away again. |
# By Matthias Kestenholz (9) and others # Via Matthias Kestenholz * v1.6.4: (26 commits) FeinCMS v1.6.4 Fix feincms#390: No longer depend on return value of add-row handler. Fix feincms#386: Do not crash in feincms_nav if no extensions registered Revert commit 3ceb1a3. The attempt at elegance caused a bug where reverse relations didn't always end up cached. Update docs/contenttypes.rst Better be safe: Escape item titles in the tree editor Make datepublisher save aware datetimes Add a test related to 3ceb1a3 VideoContent: Use protocol-relative URLs when embedding Last patch re feincms#323 was a sledgehammer to crack a walnut. This is a better solution. Fix feincms#373: Video embedding on SSL-secured websites Adding a 'force' parameter to ensure_completely_loaded, and a forced call when a content_type is added. See feincms#323 Blog entries do not have a redirect_to attribute Fix feincms#376: Intermittent crashes in RSSContent.cache_content fix AttributeError when using cleanse with section content Added patch to frontend bug cookies check Reset personal data Avoid error for unbound local variable in tag Fix feincms#366: Wrong number of parameters for get_inline_instances in Django 1.5 fix typos: i.e. stands for d.h. e.g. for z.B. ...
I have several custom page content types of the form:
If I add these to a page, and later try and delete the page I get the IntegrityError exception:
IntegrityError at /admin/page/page/82/delete/
(1451, 'Cannot delete or update a parent row: a foreign key constraint fails (
mydatabase
.page_page_mywidget
, CONSTRAINTparent_id_refs_id_54aa763d
FOREIGN KEY (parent_id
) REFERENCESpage_page
(id
))')I'm assuming this is due to an inappropriate Django ondelete handler on FK field for the page_page_mywidget table autogenerated by Page.create_content_type().
Ideally, when a page is deleted, any rows in content type tables linked to the deleted page should also be deleted. I believe this corresponds to the CASCADE ondelete behavior.
A slow and frustrating workaround is to manually delete all content types on the page, save the page, and then delete the page.
The text was updated successfully, but these errors were encountered: