django-recaptcha returning “Error: Missing required parameters: sitekey”












0














I followed the django-recaptcha directions to add a field to my contact form. When it renders (in my local test), it has a field that says "Captcha:" but no actual captcha rendered. The dev console in chrome says



 Uncaught Error: Missing required parameters: sitekey


in https://www.gstatic.com/recaptcha/api2/v1531759913576/recaptcha__en.js



This answer says to add render=explicit to the javascript, but a) I'm not sure that's even the problem, b) I would think the Django package would handle it.



Django 1.11.8, Django recaptcha 1.4.0.



Django form is



class ContactForm(forms.Form):
contacter = forms.EmailField(required=True,
label=_('Your Email (optional)'),
widget=forms.widgets.TextInput(
attrs={'size': '50'}))
contact_text = forms.CharField(required=True,
widget=forms.widgets.Textarea(
attrs={'rows': '10',
'cols': '70',
'class': 'defaultText',
'title':
_('Type a message here')}))
captcha = ReCaptchaField()


The rendered Django form is below.



  <form action="/contact/"
method="post" id="new-contact">
<input type='hidden' name='csrfmiddlewaretoken' value='...' />

<fieldset id="contact">
<legend>Contact Us</legend>
<tr><th><label for="id_contacter">Your Email (optional):</label></th><td><input type="text" name="contacter" required id="id_contacter" size="50" /></td></tr>
<tr><th><label for="id_contact_text">Contact text:</label></th><td><textarea name="contact_text" rows="10" title="Type a message here" id="id_contact_text" required cols="70" class="defaultText">
</textarea></td></tr>
<tr><th><label for="id_captcha">Captcha:</label></th><td><script src="https://www.google.com/recaptcha/api.js?hl=en"></script>
<div class="g-recaptcha" data-sitekey="" data-required="True" data-id="id_captcha" ></div>
<noscript>
<div style="width: 302px; height: 352px;">
<div style="width: 302px; height: 352px; position: relative;">
<div style="width: 302px; height: 352px; position: absolute;">
<iframe src="https://www.google.com/recaptcha/api/fallback?k="
frameborder="0" scrolling="no"
style="width: 302px; height:352px; border-style: none;">
</iframe>
</div>
<div style="width: 250px; height: 80px; position: absolute; border-style: none;
bottom: 21px; left: 25px; margin: 0px; padding: 0px; right: 25px;">
<textarea id="g-recaptcha-response" name="g-recaptcha-response"
class="recaptcha_challenge_field"
style="width: 250px; height: 80px; border: 1px solid #c1c1c1;
margin: 0px; padding: 0px; resize: none;" value="">
</textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
</div>
</div>
</div>
</noscript></td></tr>
</fieldset>

<input type="submit" value="Submit" />
</form>









share|improve this question



























    0














    I followed the django-recaptcha directions to add a field to my contact form. When it renders (in my local test), it has a field that says "Captcha:" but no actual captcha rendered. The dev console in chrome says



     Uncaught Error: Missing required parameters: sitekey


    in https://www.gstatic.com/recaptcha/api2/v1531759913576/recaptcha__en.js



    This answer says to add render=explicit to the javascript, but a) I'm not sure that's even the problem, b) I would think the Django package would handle it.



    Django 1.11.8, Django recaptcha 1.4.0.



    Django form is



    class ContactForm(forms.Form):
    contacter = forms.EmailField(required=True,
    label=_('Your Email (optional)'),
    widget=forms.widgets.TextInput(
    attrs={'size': '50'}))
    contact_text = forms.CharField(required=True,
    widget=forms.widgets.Textarea(
    attrs={'rows': '10',
    'cols': '70',
    'class': 'defaultText',
    'title':
    _('Type a message here')}))
    captcha = ReCaptchaField()


    The rendered Django form is below.



      <form action="/contact/"
    method="post" id="new-contact">
    <input type='hidden' name='csrfmiddlewaretoken' value='...' />

    <fieldset id="contact">
    <legend>Contact Us</legend>
    <tr><th><label for="id_contacter">Your Email (optional):</label></th><td><input type="text" name="contacter" required id="id_contacter" size="50" /></td></tr>
    <tr><th><label for="id_contact_text">Contact text:</label></th><td><textarea name="contact_text" rows="10" title="Type a message here" id="id_contact_text" required cols="70" class="defaultText">
    </textarea></td></tr>
    <tr><th><label for="id_captcha">Captcha:</label></th><td><script src="https://www.google.com/recaptcha/api.js?hl=en"></script>
    <div class="g-recaptcha" data-sitekey="" data-required="True" data-id="id_captcha" ></div>
    <noscript>
    <div style="width: 302px; height: 352px;">
    <div style="width: 302px; height: 352px; position: relative;">
    <div style="width: 302px; height: 352px; position: absolute;">
    <iframe src="https://www.google.com/recaptcha/api/fallback?k="
    frameborder="0" scrolling="no"
    style="width: 302px; height:352px; border-style: none;">
    </iframe>
    </div>
    <div style="width: 250px; height: 80px; position: absolute; border-style: none;
    bottom: 21px; left: 25px; margin: 0px; padding: 0px; right: 25px;">
    <textarea id="g-recaptcha-response" name="g-recaptcha-response"
    class="recaptcha_challenge_field"
    style="width: 250px; height: 80px; border: 1px solid #c1c1c1;
    margin: 0px; padding: 0px; resize: none;" value="">
    </textarea>
    <input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
    </div>
    </div>
    </div>
    </noscript></td></tr>
    </fieldset>

    <input type="submit" value="Submit" />
    </form>









    share|improve this question

























      0












      0








      0







      I followed the django-recaptcha directions to add a field to my contact form. When it renders (in my local test), it has a field that says "Captcha:" but no actual captcha rendered. The dev console in chrome says



       Uncaught Error: Missing required parameters: sitekey


      in https://www.gstatic.com/recaptcha/api2/v1531759913576/recaptcha__en.js



      This answer says to add render=explicit to the javascript, but a) I'm not sure that's even the problem, b) I would think the Django package would handle it.



      Django 1.11.8, Django recaptcha 1.4.0.



      Django form is



      class ContactForm(forms.Form):
      contacter = forms.EmailField(required=True,
      label=_('Your Email (optional)'),
      widget=forms.widgets.TextInput(
      attrs={'size': '50'}))
      contact_text = forms.CharField(required=True,
      widget=forms.widgets.Textarea(
      attrs={'rows': '10',
      'cols': '70',
      'class': 'defaultText',
      'title':
      _('Type a message here')}))
      captcha = ReCaptchaField()


      The rendered Django form is below.



        <form action="/contact/"
      method="post" id="new-contact">
      <input type='hidden' name='csrfmiddlewaretoken' value='...' />

      <fieldset id="contact">
      <legend>Contact Us</legend>
      <tr><th><label for="id_contacter">Your Email (optional):</label></th><td><input type="text" name="contacter" required id="id_contacter" size="50" /></td></tr>
      <tr><th><label for="id_contact_text">Contact text:</label></th><td><textarea name="contact_text" rows="10" title="Type a message here" id="id_contact_text" required cols="70" class="defaultText">
      </textarea></td></tr>
      <tr><th><label for="id_captcha">Captcha:</label></th><td><script src="https://www.google.com/recaptcha/api.js?hl=en"></script>
      <div class="g-recaptcha" data-sitekey="" data-required="True" data-id="id_captcha" ></div>
      <noscript>
      <div style="width: 302px; height: 352px;">
      <div style="width: 302px; height: 352px; position: relative;">
      <div style="width: 302px; height: 352px; position: absolute;">
      <iframe src="https://www.google.com/recaptcha/api/fallback?k="
      frameborder="0" scrolling="no"
      style="width: 302px; height:352px; border-style: none;">
      </iframe>
      </div>
      <div style="width: 250px; height: 80px; position: absolute; border-style: none;
      bottom: 21px; left: 25px; margin: 0px; padding: 0px; right: 25px;">
      <textarea id="g-recaptcha-response" name="g-recaptcha-response"
      class="recaptcha_challenge_field"
      style="width: 250px; height: 80px; border: 1px solid #c1c1c1;
      margin: 0px; padding: 0px; resize: none;" value="">
      </textarea>
      <input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
      </div>
      </div>
      </div>
      </noscript></td></tr>
      </fieldset>

      <input type="submit" value="Submit" />
      </form>









      share|improve this question













      I followed the django-recaptcha directions to add a field to my contact form. When it renders (in my local test), it has a field that says "Captcha:" but no actual captcha rendered. The dev console in chrome says



       Uncaught Error: Missing required parameters: sitekey


      in https://www.gstatic.com/recaptcha/api2/v1531759913576/recaptcha__en.js



      This answer says to add render=explicit to the javascript, but a) I'm not sure that's even the problem, b) I would think the Django package would handle it.



      Django 1.11.8, Django recaptcha 1.4.0.



      Django form is



      class ContactForm(forms.Form):
      contacter = forms.EmailField(required=True,
      label=_('Your Email (optional)'),
      widget=forms.widgets.TextInput(
      attrs={'size': '50'}))
      contact_text = forms.CharField(required=True,
      widget=forms.widgets.Textarea(
      attrs={'rows': '10',
      'cols': '70',
      'class': 'defaultText',
      'title':
      _('Type a message here')}))
      captcha = ReCaptchaField()


      The rendered Django form is below.



        <form action="/contact/"
      method="post" id="new-contact">
      <input type='hidden' name='csrfmiddlewaretoken' value='...' />

      <fieldset id="contact">
      <legend>Contact Us</legend>
      <tr><th><label for="id_contacter">Your Email (optional):</label></th><td><input type="text" name="contacter" required id="id_contacter" size="50" /></td></tr>
      <tr><th><label for="id_contact_text">Contact text:</label></th><td><textarea name="contact_text" rows="10" title="Type a message here" id="id_contact_text" required cols="70" class="defaultText">
      </textarea></td></tr>
      <tr><th><label for="id_captcha">Captcha:</label></th><td><script src="https://www.google.com/recaptcha/api.js?hl=en"></script>
      <div class="g-recaptcha" data-sitekey="" data-required="True" data-id="id_captcha" ></div>
      <noscript>
      <div style="width: 302px; height: 352px;">
      <div style="width: 302px; height: 352px; position: relative;">
      <div style="width: 302px; height: 352px; position: absolute;">
      <iframe src="https://www.google.com/recaptcha/api/fallback?k="
      frameborder="0" scrolling="no"
      style="width: 302px; height:352px; border-style: none;">
      </iframe>
      </div>
      <div style="width: 250px; height: 80px; position: absolute; border-style: none;
      bottom: 21px; left: 25px; margin: 0px; padding: 0px; right: 25px;">
      <textarea id="g-recaptcha-response" name="g-recaptcha-response"
      class="recaptcha_challenge_field"
      style="width: 250px; height: 80px; border: 1px solid #c1c1c1;
      margin: 0px; padding: 0px; resize: none;" value="">
      </textarea>
      <input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
      </div>
      </div>
      </div>
      </noscript></td></tr>
      </fieldset>

      <input type="submit" value="Submit" />
      </form>






      django django-recaptcha






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 20 '18 at 0:38









      dfrankowdfrankow

      8,5743198150




      8,5743198150
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I also filed this issue here.



          Setting RECAPTCHA_PRIVATE_KEY and RECAPTCHA_PUBLIC_KEY to empty strings as directed produces this error. If instead those variables are completely unset (in the Django settings for the dev environment), the library uses the test keys, and all is well.






          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%2f51922897%2fdjango-recaptcha-returning-error-missing-required-parameters-sitekey%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 also filed this issue here.



            Setting RECAPTCHA_PRIVATE_KEY and RECAPTCHA_PUBLIC_KEY to empty strings as directed produces this error. If instead those variables are completely unset (in the Django settings for the dev environment), the library uses the test keys, and all is well.






            share|improve this answer


























              0














              I also filed this issue here.



              Setting RECAPTCHA_PRIVATE_KEY and RECAPTCHA_PUBLIC_KEY to empty strings as directed produces this error. If instead those variables are completely unset (in the Django settings for the dev environment), the library uses the test keys, and all is well.






              share|improve this answer
























                0












                0








                0






                I also filed this issue here.



                Setting RECAPTCHA_PRIVATE_KEY and RECAPTCHA_PUBLIC_KEY to empty strings as directed produces this error. If instead those variables are completely unset (in the Django settings for the dev environment), the library uses the test keys, and all is well.






                share|improve this answer












                I also filed this issue here.



                Setting RECAPTCHA_PRIVATE_KEY and RECAPTCHA_PUBLIC_KEY to empty strings as directed produces this error. If instead those variables are completely unset (in the Django settings for the dev environment), the library uses the test keys, and all is well.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 19 '18 at 20:13









                dfrankowdfrankow

                8,5743198150




                8,5743198150






























                    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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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%2f51922897%2fdjango-recaptcha-returning-error-missing-required-parameters-sitekey%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

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith