title: AJAX not working in django production mode?
body: <p>I've a django app deployed on heroku. In one of the section I asks for feedback and email of the person. If the email is valid email then I just reply Thank you. This is all being done using AJAX from getting values of form to returning thank you. It works fine in developement mode but not in prouction mode. </p>
  
  <p>Here's my 'index.js'</p>
  
  <pre><code>function valid(email)
  {
      var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
      return emailReg.test(email); 
  }
  
  $(document).on('submit','.Myform',function(e){
      e.preventDefault();
  
      $.ajax({
          type:'POST',
          url:'',
          data:{
              message:$('#id_message').val(),
              email:$('#id_email').val(),
              csrfmiddlewaretoken:$('input[name=csrfmiddlewaretoken]').val(),
          },
          success: function() {
              let validate = valid($('#id_email').val());
              if(validate){
                  $('.Myform').fadeOut();
                  $('.thank_you').fadeIn();
              }
              else{
                  $('.Myform').show();
                  alert('Please enter valid email address.');
              }
          }
      });
  });
  </code></pre>
  
  <p>I've only one view in my app. So transferring data of AJAX to that view.</p>
  
  <p>Here's my <code>views.py</code></p>
  
  <pre><code>def index(request):
  
      if request.method == 'POST':
          form = FeedbackForm(request.POST)
          if form.is_valid():
              message = request.POST['message']
              email = request.POST['email']
              print(message)
              print(email)
              subject = "{} by {}".format(message,email)
              recipients = ['xyz@mail.com']
              sender = 'my@mail.com'
              send_mail(subject, message, sender ,recipients,fail_silently=False)
              return HttpResponse('')
      else:
          form = ThoughtForm()
  
      return render(request,'my_webapp/index.html',{'form':form})
  </code></pre>
  
  <p>My <code>urls.py</code> file-</p>
  
  <pre><code>urlpatterns = [
      path('',views.index,name='index')
  ]
  </code></pre>
  
  <p>In developement mode- It all works well. </p>
  
  <p><strong>In production mode as soon as I hit submit button it shows me the loading gif but then it dissappears with no thank you message, no wrong email alert nothing happens and form vanishes</strong> </p>
  
  <p>The issue seems to be with the url. Can somebody help.</p>
  
  <p>Here's the traceback error I'm getting in heroku logs-</p>
  
  <pre><code>Internal Server Error: /
  2019-10-07T18:30:33.977239+00:00 app[web.1]: Traceback (most recent call last):
  2019-10-07T18:30:33.977241+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
  2019-10-07T18:30:33.977243+00:00 app[web.1]: response = get_response(request)
  2019-10-07T18:30:33.977246+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
  2019-10-07T18:30:33.977248+00:00 app[web.1]: response = self.process_exception_by_middleware(e, request)
  2019-10-07T18:30:33.97725+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
  2019-10-07T18:30:33.977253+00:00 app[web.1]: response = wrapped_callback(request, *callback_args, **callback_kwargs)
  2019-10-07T18:30:33.977255+00:00 app[web.1]: File "/app/my_webapp/views.py", line 27, in index
  2019-10-07T18:30:33.977257+00:00 app[web.1]: send_mail(subject, thoughts, sender ,recipients,fail_silently=False)
  2019-10-07T18:30:33.977259+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/mail/__init__.py", line 60, in send_mail
  2019-10-07T18:30:33.977261+00:00 app[web.1]: return mail.send()
  2019-10-07T18:30:33.977263+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/mail/message.py", line 291, in send
  2019-10-07T18:30:33.977265+00:00 app[web.1]: return self.get_connection(fail_silently).send_messages([self])
  2019-10-07T18:30:33.977267+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/mail/backends/smtp.py", line 103, in send_messages
  2019-10-07T18:30:33.977269+00:00 app[web.1]: new_conn_created = self.open()
  2019-10-07T18:30:33.977271+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/mail/backends/smtp.py", line 70, in open
  2019-10-07T18:30:33.977273+00:00 app[web.1]: self.connection.login(self.username, self.password)
  2019-10-07T18:30:33.977275+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/smtplib.py", line 730, in login
  2019-10-07T18:30:33.977277+00:00 app[web.1]: raise last_exception
  2019-10-07T18:30:33.977279+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/smtplib.py", line 721, in login
  2019-10-07T18:30:33.977281+00:00 app[web.1]: initial_response_ok=initial_response_ok)
  2019-10-07T18:30:33.977283+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/smtplib.py", line 642, in auth
  2019-10-07T18:30:33.977285+00:00 app[web.1]: raise SMTPAuthenticationError(code, resp)
  2019-10-07T18:30:33.977446+00:00 app[web.1]: smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8  https://support.google.com/mail/?p=BadCredentials q2sm7667020qkc.68 - gsmtp')
  2019-10-07T18:30:33.978833+00:00 app[web.1]: 10.51.220.16 - - [07/Oct/2019:18:30:33 +0000] "POST / HTTP/1.1" 500 13750 "https://application.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0"
  2019-10-07T18:30:33.980844+00:00 heroku[router]: at=info method=POST path="/" host=application.herokuapp.com request_id=9bfdde45-dc5c-4fc6-bcee-4cdd3dd5aa72 fwd="103.212.146.48" dyno=web.1 connect=7ms service=191ms status=500 bytes=13976 protocol=https
  </code></pre>