6👍
This issue is caused when you are not subclassing the PlaceholderAdminField
in your admin class.
For example:
from cms.admin.placeholderadmin import PlaceholderAdmin
from cms.models.fields import PlaceholderField
class MyModel(models.Model):
name = models.CharField(max_length=100)
sidebar = PlaceholderField('sidebar')
class MyAdmin(PlaceholderAdmin):
""" Put your usual admin stuff here. If you use fieldset,
include the sidebar as its own tuple """
fieldsets = (
(None, {
'fields': ('name',),
}),
('Sidebar', {
'classes': ('plugin-holder', 'plugin-holder-nopage'),
'fields': ('sidebar',)
}),
)
admin.site.register(MyModel, MyAdmin)
0👍
Well, this appears to be a bug in Django-CMS. I’ve never used it, but looking at the code, it’s clear that the default formfield for PlaceholderField
creates a lambda which takes a single argument – a queryset, but the render function for that formfield calls the lambda with two arguments – the request, and the queryset.
Probably the best way to fix this is to define your own subclass of PlaceholderField
which redefines the formfield
method so it returns a correct lambda:
class FixedPlaceholderField(PlaceholderField):
def formfield(self, **kwargs):
return self.formfield_for_admin(None, lambda request, qs: qs, **kwargs)
and use this field in your model instead.
If this fixes it, it’s probably worth raising a bug in Django-CMS.
- [Django]-Using TEMPLATE_STRING_IF_INVALID with Django 1.8
- [Django]-Django 'User' object has no attribute 'user'
0👍
Ok. I’ve solved the problem for me. I still don’t know what was happening but maybe my answer will help you figure it out ;).
I’ve used a method:
def formfield_for_dbfield(self, db_field, **kwargs):
...
which substituted one text field into TinyMCE editor. When I removed the whole method the problem vanished. If I have time later on maybe I’ll try to dig into it a little bit deeper.
I’m still not convinced that that was the only problem. I have a hunch that it also might be something with data because I’ve filled placeholder with text plugin from code.
Hope it helps somehow.
- [Django]-Django rest framework ignores missing csrf tokens with httpie
- [Django]-"error": "invalid_client" django-oauth-toolkit
- [Django]-How to stop PyCharm from autocompleting HTML and Django template tags?