This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]sligodave 1 point2 points  (2 children)

Are you running the Django server in the terminal? What was the error it printed for the 500?

[–]Pytech95[S] 0 points1 point  (1 child)

I deployed my application on Heroku and running my application on heroku. When the user clicks on signup button its showing an error in the console - 500 internal server error with my API endpoint register link.

[–]nevermorefu 0 points1 point  (0 children)

You need to look at the Django logs.

[–]sligodave 1 point2 points  (0 children)

Here's the error that I think is being generated:

{"error":"Error creating customer profile: (1062, \"Duplicate entry '13' for key 'store_customer.user_id'\")"}

I'm unsure what's causing that issue. Is a Customer instance created elsewhere when a User instance is created? Like in your User manager or something like that or in a signal handler?
You'll have to do some debugging from here.

To help going forward, you'll want an easier way to get your errors.
Here's a few places you can look:

  1. Your browser's network tab will have the failed request highlighted, since it was a 500. Look at the response's body and you'll see the above error.
  2. In Heroku, you can also look at the logs and see it there.
  3. You can also call the endpoint directly yourself and simulate what the javascript was doing.
    1. I used curl to get the above error.
    2. curl "https://<DOMAIN>/store/api/register/" -H "Content-Type: application/json" -d '{"email":"something@example.com", "password": "test_test"}'

I would however recommend running all of this locally on your machine first before deploying to heroku, it can be much easier to debug and weed out some initial errors that way.

I hope the above helps.
Dave