Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PlaceholderAdmin throws <lambda>() takes exactly 1 argument (2 given)

I've wrote a plugin for django-cms which has it's own model with one PlaceholderField. When I add a PlaceholderAdmin for model admin I'm getting this on admin site:

Exception Type: TemplateSyntaxError
Exception Value:    
Caught TypeError while rendering: <lambda>() takes exactly 1 argument (2 given)
Exception Location: <blablapath>/python2.6/site-packages/cms/forms/widgets.py in render, line 199

I've been searching for solution and found only some problems with django-cms example which would not run without uncommenting some path in urls.py so I guess it might be problem with urls, especially that I do some magic in my urls. The question is: what conditions should hold for django-cms url's to be valid? Any ideas? Any solutions? Anybody had this problem before?

like image 401
code22 Avatar asked Apr 19 '26 03:04

code22


1 Answers

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)
like image 199
damon Avatar answered Apr 22 '26 15:04

damon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!