Passing session data to ModelForm inside of ModelAdmin

Posted by theactiveactor on Stack Overflow See other posts from Stack Overflow or by theactiveactor
Published on 2010-05-30T15:10:11Z Indexed on 2010/05/30 15:12 UTC
Read the original article Hit count: 262

Filed under:
|

I'm trying to initialize the form attribute for MyModelAdmin class inside an instance method, as follows:

class MyModelAdmin(admin.ModelAdmin): 
    def queryset(self, request):
        MyModelAdmin.form = MyModelForm(request.user)

My goal is to customize the editing form of MyModelForm based on the current session. When I try this however, I keep getting an error (shown below). Is this the proper place to pass session data to ModelForm? If so, then what may be causing this error?

TypeError at ...

Exception Type: TypeError

Exception Value: issubclass() arg 1 must be a class

Exception Location: /usr/lib/pymodules/python2.6/django/forms/models.py in new, line 185

© Stack Overflow or respective owner

Related posts about django

Related posts about django-admin