Accessing django app from another app with ajax

62 views
Skip to first unread message

Larry Martell

unread,
Mar 25, 2015, 9:05:11 PM3/25/15
to django...@googlegroups.com
I have a webservice written in django and I want to call it from a non
django app with ajax. Both apps run on the same host. When I call the
webservice with curl it works fine, but when I call it with ajax from
the other app I get a 500 internal server error. There are no errors
in the web server log. DEBUG is True, and ALLOWED_HOSTS = ['*']. When
I run the dev server and connect to that I get no errors, just the 500
error. I tried setting a breakpoint in the view, but it never makes it
there.

Anyone have any ideas as to why this is happening or how I could debug
it further?

aRkadeFR

unread,
Mar 26, 2015, 7:27:29 AM3/26/15
to django...@googlegroups.com
Do you have the stacktrace? Without it it's gonna be hard
to help you.

My only guess is CORS (Cross-Origin Resource Sharing)? But
you should have the same error on local dev if you have similar
setup from your production.

Larry Martell

unread,
Mar 26, 2015, 7:29:03 AM3/26/15
to django...@googlegroups.com
On Thu, Mar 26, 2015 at 7:22 AM, aRkadeFR <con...@arkade.info> wrote:
> Do you have the stacktrace? Without it it's gonna be hard
> to help you.
>
> My only guess is CORS (Cross-Origin Resource Sharing)? But
> you should have the same error on local dev if you have similar
> setup from your production.

There was no stacktrace. But I figured that this issue - I did not
have a slash on the end of the URL. I added that, then instead of a
500 I got a 403 Forbidden, because it didn't like the CSRF token, but
I am sending that. So I disabled CSRF and then I get a 400 bad
request, again no stacktrace. ALLOWED_HOSTS is ['*'] so that's not the
cause.


>
>
> On 03/26/2015 02:04 AM, Larry Martell wrote:
>>
>> I have a webservice written in django and I want to call it from a non
>> django app with ajax. Both apps run on the same host. When I call the
>> webservice with curl it works fine, but when I call it with ajax from
>> the other app I get a 500 internal server error. There are no errors
>> in the web server log. DEBUG is True, and ALLOWED_HOSTS = ['*']. When
>> I run the dev server and connect to that I get no errors, just the 500
>> error. I tried setting a breakpoint in the view, but it never makes it
>> there.
>>
>> Anyone have any ideas as to why this is happening or how I could debug
>> it further?
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5513EBD8.2060809%40arkade.info.
> For more options, visit https://groups.google.com/d/optout.

aRkadeFR

unread,
Mar 26, 2015, 10:20:16 AM3/26/15
to django...@googlegroups.com
You should setup your project so you're able to retrieve the
stacktrace on a 500 server error.

Larry Martell

unread,
Mar 26, 2015, 10:26:58 AM3/26/15
to django...@googlegroups.com
On Thu, Mar 26, 2015 at 10:20 AM, aRkadeFR <con...@arkade.info> wrote:
> You should setup your project so you're able to retrieve the
> stacktrace on a 500 server error.

When there is a stack trace I get it (e.g. when I was getting the 403
error). There was no stack trace when I was getting the 500. But the
500 is resolved. I am now fighting the 400 error, which also gives no
stack trace.

Filipe Ximenes

unread,
Mar 26, 2015, 10:42:07 AM3/26/15
to django...@googlegroups.com
In case there's no one using your project and there's no sensitive data in it, you can briefly set DEBUB to True in the server to see stack traces. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.



--
  
Filipe Ximenes
+55 (81) 8245-9204
Vinta Software Studio
http://www.vinta.com.br

aRkadeFR

unread,
Mar 26, 2015, 10:42:53 AM3/26/15
to django...@googlegroups.com
But from the first email, the debug settings is already at True
and he is not getting a stacktrace...

Filipe Ximenes

unread,
Mar 26, 2015, 10:49:08 AM3/26/15
to django...@googlegroups.com
My mistake. 



For more options, visit https://groups.google.com/d/optout.

aRkadeFR

unread,
Mar 26, 2015, 11:28:05 AM3/26/15
to django...@googlegroups.com
No problem we agree that having a stacktrace would be
a better way to debug it.

Even on a 400 :)
Reply all
Reply to author
Forward
0 new messages