Comments (35)
Any other soul having the issue? I need to decide whether to use Django CMS 4 for more complex solutions or not. It really is a deal-breaker for me at the moment since I have incoming projects with the same principle of hooking up pages.
I couldn't find anything related in the docs, or I missed it.
Thanks a lot!
from django-cms.
I have not encountered this issue when using multiple instances of namespaced apphooks.
I wonder what Placeholder you are adding the custom plugins to. While django CMS 3 allowed access to page placeholders on apphook root pages, this was never a documented feature and is not immediately possible for v4 without making them explicitly available and set them for the toolbar (see #7712).
I am suspecting you are somehow accessing the wrong placeholder and the permission denied is coming from the fact that the placeholder belongs to a published (and therefore write-protected) page. But that's just a stab in the dark.
Can you check which placeholders you are trying to add plugins to. Are they different for the instances (they should)? Do they belong to a publsihed object?
from django-cms.
Hmmm. I am actually using my default "Content" template with "Content" placeholder. AppHook role is actually just to be able to hook the URL root to the CMS page (to be able to get e.g. /serial-production/1/test-product/ or /handmade-production/2/another-test-product/
The point is controlling the list through my CMS plugin added to "Content" placeholder (e.g. items shown on 1 page) and/or adding a Disclaimer at the bottom of the list.
Indeed v3 allowed this and it was an awesome feature since clients often ask for display control through plugins.
I am not sure I understand why this is not possible in v4 since the Toolbar is not involved at all. It is not the detail page with PlaceholderMixin "deep down the url structure".
And the weird thing is that it works as expected on my Page 1. When same Apphook with different namespace is added to Page 2 the error appears.
Thanks in advance.
from django-cms.
The reason this changed in v4 are the edit and preview endpoints. The toolbar is the thing allowing you to edit a page in the first place. So it is involved. ;-) The edit endpoints for your apphook will get the apphook view which then must advertise which model instance is to be edited or previewed. This happened implicitly in v3 through the URL of the page (which also was a URL for a valid page).
So you must be doing something in your view to show the placeholder. I assume this code causes the issue. The issue in linked contains a snipped which will advertise the page content object for the apphook's root URL. Maybe it solves your problem? Maybe you can share your apphook root view's code?
from django-cms.
@fsbraun my bad for not understanding. It may sound a little hostile in my previous reply but it really wasn't (when I read it again it really could have been misinterpreted).
My urls.py
has only the detail URL:
urlpatterns = [
re_path(r'^(?P<product_id>[\d]+)/(?P<product_slug>[\w-]+)/', ProductDetail.as_view(), name='product_detail'),
]
AppHook root is not defined since I am using a custom Plugin with list queryset which is added to my "Content" placeholder.
My cms_app_config.py
class CMSConfigApp(CMSApp):
def get_configs(self):
return self.app_config.objects.all()
def get_config(self, namespace):
try:
return self.app_config.objects.get(namespace=namespace)
except ObjectDoesNotExist:
return None
def get_config_add_url(self):
try:
return reverse('admin:%s_%s_add' % (self.app_config._meta.app_label,
self.app_config._meta.model_name))
except: # pragma: no cover
return reverse('admin:%s_%s_add' % (self.app_config._meta.app_label,
self.app_config._meta.module_name))
My cms_apps.py
@apphook_pool.register
class ProductsApp(CMSConfigApp):
app_config = Category
app_name = 'products'
name = _('Products')
def get_urls(self, page=None, language=None, **kwargs):
return ['myappname.app.products.urls']
My cms_plugins.py
@plugin_pool.register_plugin
class ProductsListPlugin(CMSPluginBase):
model = ProductListCMSPlugin
module = _("Products")
name = _('Products list')
render_template = "products/plugins/products_list_plugin.html"
cache = False
def render(self, context, instance, placeholder):
context = super(ProductsListPlugin, self).render(context, instance, placeholder)
category = instance.category
paginated_items = instance.paginated_items
try:
products = Product.objects.filter(category=category, published=True).order_by('order')
except category.DoesNotExist or category is None:
products = Product.objects.filter(published=True).order_by('order')
context.update({
'products': products,
'paginated_items': paginated_items
})
return context
DB screenshot for these AppHooked pages.
I hope it clarifies my setup.
from django-cms.
Everything's all right - no worries!! OK, I now understand that you do not have a root URL defined for your apphook. I will need some time to take a look and try to reproduce.
from django-cms.
I thought it is better to write-out my code. It is a bit unusual but it gives a lot of flexibility, especially as some of my clients want to be able to change "almost" everything. Maybe someone will also find it helpful :D
Thanks a lot for your help.
from django-cms.
Related Issues (20)
- error install djangocms-blog HOT 2
- [feat] Without public home page, a 404 error is raised HOT 18
- [BUG] toolbar.obj is not set correctly in edit view when apphook landing page is a CMS page HOT 2
- Bounty program HOT 2
- [BUG] The sign up page https://www.django-cms.org/en/sign-up-work-contribution/ doesn't get pass the catchup HOT 1
- [BUG] Migrating with another database other than "default" HOT 3
- [BUG] Placeholder inherit raising "NoneType should implement get_template" if used on an apphooked page HOT 2
- [BUG] With versioning enabled, "Show in Menu" does not work in page tree HOT 2
- [BUG] 404 page not found error without a trailing slash for "/en" and "/en/admin" URLs. HOT 1
- [DOC] code update
- [BUG] create_page_content API adding two cms_pagecontent records instead of one HOT 3
- [BUG] A new page can be edited after creation
- add language page return coroutine object has no attribute 'set_cookie' [BUG] HOT 2
- add language HOT 2
- [ENHANCEMENT] Add RTL support for the pagetree HOT 4
- [BUG] `./manage.py cms delete_orphaned_plugins` might create an inconsistent plugin tree
- fix separately
- Clarify the necessity of this and the line above
- [BUG] Cms check show wrong error HOT 3
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-cms.