KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I get the following error when instantiating a Django form with a the constructor overriden: __init__() got multiple values for keyword argument 'collection_type' The __init__() function (shown below) is exactly as written this but with # code replaced with my logic. Asside from that I am essentially overriding the form's (which is a ModelForm) constructor. def __init__(self, collection_type, user=None, parent=None, *args, **kwargs): # code super(self.__class__, self).__init__(*args, **kwargs) The call that creates the error is shown here: form = CreateCollectionForm( request.POST, collection_type=collection_type, parent=parent, user=request.user ) I cannot see any reason why the error is popping up. EDIT: Here is the full code for the constructor def __init__(self, collection_type, user=None, parent=None, *args, **kwargs): self.collection_type = collection_type if self.collection_type == 'library': self.user = user elif self.collection_type == 'bookshelf' or self.collection_type == 'series': self.parent = parent else: raise AssertionError, 'collection_type must be "library", "bookshelf" or "series"' super(self.__class__, self).__init__(*args, **kwargs) EDIT: Stacktrace Environment: Request Method: POST Request URL: http://localhost:8000/forms/create_bookshelf/hello Django Version: 1.1.1 Python Version: 2.6.1 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'libraries', 'users', 'books', 'django.contrib.admin', 'googlehooks', 'registration'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware'
Tags (comma-separated)
Save Edits
Cancel