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;








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)
....









share|improve this question






















  • If 'instance' is also define in your kwargs that you are passing, that would explain the error.

    – Nic Laforge
    Mar 25 at 13:22

















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)
....









share|improve this question






















  • If 'instance' is also define in your kwargs that you are passing, that would explain the error.

    – Nic Laforge
    Mar 25 at 13:22













0












0








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)
....









share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












1 Answer
1






active

oldest

votes


















0














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 instanceis 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)





share|improve this answer






















    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    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 instanceis 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)





    share|improve this answer



























      0














      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 instanceis 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)





      share|improve this answer

























        0












        0








        0







        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 instanceis 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)





        share|improve this answer













        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 instanceis 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)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 26 at 3:04









        mark233mark233

        11 bronze badge




        11 bronze badge


















            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.



















            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

            밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

            1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴