TypeError: __init__() got multiple values for argument 'instance'Django: multiple values for keyword argument 'initial'Can I get django-oscar to work under Python 3?error 'NoneType' object has no attribute '__dict__'Win10 Django: NoReverseMatch at / Reverse for 'index' with arguments '()' and keyword arguments '' not found. 0 pattern(s) tried: []Django Error on edit in Django adminUsing microsoft cognitive services in Djangoasyncio in django viewDjango TypeError at /account/register/ 'tuple' object is not callableDjango - No such table: main.auth_user__oldPython 2 to 3 migration: AttributeError: 'int' object has no attribute 'replace'
What does the phrase "building hopping chop" mean here?
How can I write a panicked scene without it feeling like it was written in haste?
Boolean Difference with Offset?
Security Patch SUPEE-11155 - Possible issues?
How did installing this RPM create a file?
Balanced parentheses using STL C++
Is there reliable evidence that depleted uranium from the 1999 NATO bombing is causing cancer in Serbia?
How can a valley surrounded by mountains be fertile and rainy?
Does a return economy-class seat between London and San Francisco release 5.28 t of CO2e?
Can Aziraphale and Crowley actually become native?
Is the location of an aircraft spoiler really that vital?
Adjective for 'made of pus' or 'corrupted by pus' or something of something of pus
Are all commands with an optional argument fragile?
I'm reinstalling my Linux desktop, how do I keep SSH logins working?
Can a function nowhere continuous have a connected graph?
What does grep -v "grep" mean and do?
How does Resilient sphere (cast via contingency) interact with an existing Silence spell?
Symbol for "not absolutely continuous" in Latex
Step into the Octagram
How can my story take place on Earth without referring to our existing cities and countries?
Why do I need two parameters in an HTTP parameter pollution attack?
Could human civilization live 150 years in a nuclear-powered aircraft carrier colony without resorting to mass killing/ cannibalism?
Why do changes to /etc/hosts take effect immediately?
Golf the smallest circle!
TypeError: __init__() got multiple values for argument 'instance'
Django: multiple values for keyword argument 'initial'Can I get django-oscar to work under Python 3?error 'NoneType' object has no attribute '__dict__'Win10 Django: NoReverseMatch at / Reverse for 'index' with arguments '()' and keyword arguments '' not found. 0 pattern(s) tried: []Django Error on edit in Django adminUsing microsoft cognitive services in Djangoasyncio in django viewDjango TypeError at /account/register/ 'tuple' object is not callableDjango - No such table: main.auth_user__oldPython 2 to 3 migration: AttributeError: 'int' object has no attribute 'replace'
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I was tring to keep ckeditor and markdown at same time in a edit/(add new post) in blog web backend, so i modifid __init__
,after that,i can still open edit page .but,once I click save button, this error came out:TypeError: __init__() got multiple values for argument 'instance'
Traceback (most recent call last):
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 604, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoviewsdecoratorscache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminsites.py", line 223, in inner
return view(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1640, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 45, in _wrapper
return bound_method(*args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1525, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1556, in _changeform_view
form = ModelForm(request.POST, request.FILES, instance=obj)
TypeError: __init__() got multiple values for argument 'instance'
this is the part where once i delete, error won't come out:
blog/adminforms.py
class PostAdmin(forms.ModelForm):
....
def __init__(self, instance=None, initial=None, **kwargs):
initial = initial or
if instance:
if instance.is_md:
initial['content_md'] = instance.content
else:
initial['content_ck'] = instance.content
super().__init__(instance=instance, initial=initial, **kwargs)
....
python-3.x django-2.1
add a comment |
I was tring to keep ckeditor and markdown at same time in a edit/(add new post) in blog web backend, so i modifid __init__
,after that,i can still open edit page .but,once I click save button, this error came out:TypeError: __init__() got multiple values for argument 'instance'
Traceback (most recent call last):
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 604, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoviewsdecoratorscache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminsites.py", line 223, in inner
return view(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1640, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 45, in _wrapper
return bound_method(*args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1525, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1556, in _changeform_view
form = ModelForm(request.POST, request.FILES, instance=obj)
TypeError: __init__() got multiple values for argument 'instance'
this is the part where once i delete, error won't come out:
blog/adminforms.py
class PostAdmin(forms.ModelForm):
....
def __init__(self, instance=None, initial=None, **kwargs):
initial = initial or
if instance:
if instance.is_md:
initial['content_md'] = instance.content
else:
initial['content_ck'] = instance.content
super().__init__(instance=instance, initial=initial, **kwargs)
....
python-3.x django-2.1
If 'instance' is also define in your kwargs that you are passing, that would explain the error.
– Nic Laforge
Mar 25 at 13:22
add a comment |
I was tring to keep ckeditor and markdown at same time in a edit/(add new post) in blog web backend, so i modifid __init__
,after that,i can still open edit page .but,once I click save button, this error came out:TypeError: __init__() got multiple values for argument 'instance'
Traceback (most recent call last):
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 604, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoviewsdecoratorscache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminsites.py", line 223, in inner
return view(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1640, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 45, in _wrapper
return bound_method(*args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1525, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1556, in _changeform_view
form = ModelForm(request.POST, request.FILES, instance=obj)
TypeError: __init__() got multiple values for argument 'instance'
this is the part where once i delete, error won't come out:
blog/adminforms.py
class PostAdmin(forms.ModelForm):
....
def __init__(self, instance=None, initial=None, **kwargs):
initial = initial or
if instance:
if instance.is_md:
initial['content_md'] = instance.content
else:
initial['content_ck'] = instance.content
super().__init__(instance=instance, initial=initial, **kwargs)
....
python-3.x django-2.1
I was tring to keep ckeditor and markdown at same time in a edit/(add new post) in blog web backend, so i modifid __init__
,after that,i can still open edit page .but,once I click save button, this error came out:TypeError: __init__() got multiple values for argument 'instance'
Traceback (most recent call last):
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersexception.py", line 34, in inner
response = get_response(request)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersbase.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocorehandlersbase.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 604, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoviewsdecoratorscache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminsites.py", line 223, in inner
return view(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1640, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 45, in _wrapper
return bound_method(*args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangoutilsdecorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1525, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "E:python_worksprojectdjangotypeidea-envlibsite-packagesdjangocontribadminoptions.py", line 1556, in _changeform_view
form = ModelForm(request.POST, request.FILES, instance=obj)
TypeError: __init__() got multiple values for argument 'instance'
this is the part where once i delete, error won't come out:
blog/adminforms.py
class PostAdmin(forms.ModelForm):
....
def __init__(self, instance=None, initial=None, **kwargs):
initial = initial or
if instance:
if instance.is_md:
initial['content_md'] = instance.content
else:
initial['content_ck'] = instance.content
super().__init__(instance=instance, initial=initial, **kwargs)
....
python-3.x django-2.1
python-3.x django-2.1
asked Mar 25 at 13:19
mark233mark233
11 bronze badge
11 bronze badge
If 'instance' is also define in your kwargs that you are passing, that would explain the error.
– Nic Laforge
Mar 25 at 13:22
add a comment |
If 'instance' is also define in your kwargs that you are passing, that would explain the error.
– Nic Laforge
Mar 25 at 13:22
If 'instance' is also define in your kwargs that you are passing, that would explain the error.
– Nic Laforge
Mar 25 at 13:22
If 'instance' is also define in your kwargs that you are passing, that would explain the error.
– Nic Laforge
Mar 25 at 13:22
add a comment |
1 Answer
1
active
oldest
votes
I fonud solution here:
Django: multiple values for keyword argument 'initial'
It is a same problem as mine,generally speaking.somehow, the instance
pass todef __init__(self, instance=None, initial=None, **kwargs):
is not receive by instance
,instead it passed to kwargs
(still don't know why),then intance
is default to beNone
,so there are two inastance
parameters,the first instance which is default to be None
,the second instance
is in kwargs
which is the real one i want to pass
so that what i done to fix it:
def __init__(self, *args, **kwargs):
initial = kwargs.get('initial') or
instance = kwargs.get('instance')
if instance:
if instance.is_md:
initial['content_md'] = instance.content
else:
initial['content_ck'] = instance.content
kwargs.update('instance':instance,'initial':initial)
super().__init__(*args,**kwargs)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55338745%2ftypeerror-init-got-multiple-values-for-argument-instance%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I fonud solution here:
Django: multiple values for keyword argument 'initial'
It is a same problem as mine,generally speaking.somehow, the instance
pass todef __init__(self, instance=None, initial=None, **kwargs):
is not receive by instance
,instead it passed to kwargs
(still don't know why),then intance
is default to beNone
,so there are two inastance
parameters,the first instance which is default to be None
,the second instance
is in kwargs
which is the real one i want to pass
so that what i done to fix it:
def __init__(self, *args, **kwargs):
initial = kwargs.get('initial') or
instance = kwargs.get('instance')
if instance:
if instance.is_md:
initial['content_md'] = instance.content
else:
initial['content_ck'] = instance.content
kwargs.update('instance':instance,'initial':initial)
super().__init__(*args,**kwargs)
add a comment |
I fonud solution here:
Django: multiple values for keyword argument 'initial'
It is a same problem as mine,generally speaking.somehow, the instance
pass todef __init__(self, instance=None, initial=None, **kwargs):
is not receive by instance
,instead it passed to kwargs
(still don't know why),then intance
is default to beNone
,so there are two inastance
parameters,the first instance which is default to be None
,the second instance
is in kwargs
which is the real one i want to pass
so that what i done to fix it:
def __init__(self, *args, **kwargs):
initial = kwargs.get('initial') or
instance = kwargs.get('instance')
if instance:
if instance.is_md:
initial['content_md'] = instance.content
else:
initial['content_ck'] = instance.content
kwargs.update('instance':instance,'initial':initial)
super().__init__(*args,**kwargs)
add a comment |
I fonud solution here:
Django: multiple values for keyword argument 'initial'
It is a same problem as mine,generally speaking.somehow, the instance
pass todef __init__(self, instance=None, initial=None, **kwargs):
is not receive by instance
,instead it passed to kwargs
(still don't know why),then intance
is default to beNone
,so there are two inastance
parameters,the first instance which is default to be None
,the second instance
is in kwargs
which is the real one i want to pass
so that what i done to fix it:
def __init__(self, *args, **kwargs):
initial = kwargs.get('initial') or
instance = kwargs.get('instance')
if instance:
if instance.is_md:
initial['content_md'] = instance.content
else:
initial['content_ck'] = instance.content
kwargs.update('instance':instance,'initial':initial)
super().__init__(*args,**kwargs)
I fonud solution here:
Django: multiple values for keyword argument 'initial'
It is a same problem as mine,generally speaking.somehow, the instance
pass todef __init__(self, instance=None, initial=None, **kwargs):
is not receive by instance
,instead it passed to kwargs
(still don't know why),then intance
is default to beNone
,so there are two inastance
parameters,the first instance which is default to be None
,the second instance
is in kwargs
which is the real one i want to pass
so that what i done to fix it:
def __init__(self, *args, **kwargs):
initial = kwargs.get('initial') or
instance = kwargs.get('instance')
if instance:
if instance.is_md:
initial['content_md'] = instance.content
else:
initial['content_ck'] = instance.content
kwargs.update('instance':instance,'initial':initial)
super().__init__(*args,**kwargs)
answered Mar 26 at 3:04
mark233mark233
11 bronze badge
11 bronze badge
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55338745%2ftypeerror-init-got-multiple-values-for-argument-instance%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If 'instance' is also define in your kwargs that you are passing, that would explain the error.
– Nic Laforge
Mar 25 at 13:22