JQuery.getJSON()的URL?

I am following this example to get variable inlines for my Django admin page. Everything is functioning until this line in the javascript function:

$.getJSON('/ajax/category-type/', .....)

where the server comes up with a 404 for /ajax/category-type/. I'm not very familiar with AJAX (or JSONs) so I'm not sure what the issue is.

Is this a placeholder URL that I need to fill in? Am I missing a dependency? (I tried installing django-ajax to my project but that didn't change anything.)

I feel like this is probably something stupid simple that I'm missing.

Edit:

I did need to add this url to my urls.py, but that only partially fixed the problem.

After fixing that problem, I added a print statement to the view, which confirms that it's being hit when I go to the admin page. But immediately following that, I'm still getting the same 404 error in the server. It's always getting a 404 from the line categories = get_list_or_404(Category, id=id). I believe this should be getting all the Categorys with the id, but I'm not sure what the id actually is in this case.

Your ajax URL needs to point to a valid resource on your backend (django). I'm not terribly familiar with django, but if it's a REST framework you can probably define resources on your backend by defining routes, e.g. 'api/users/{id}', which might return users by their ID. But it needs to be something you've defined beforehand. Looks like there's some documentation on this:

https://docs.djangoproject.com/en/dev/topics/http/urls/

One way you can tell if it's a valid URL to ajax (getJSON) to is to put it in your browser and see if it comes back with anything. You'll need to include the domain as well when you put it in your browser of course, e.g. http://localhost:64611/ajax/category-type/