joestump / django-ajax

A simple framework for creating AJAX endpoints in Django.
http://github.com/joestump/django-ajax
BSD 3-Clause "New" or "Revised" License
260 stars 54 forks source link

URL case sensitivity #15

Closed MattFisher closed 12 years ago

MattFisher commented 13 years ago

I think it needs to be made clear that the model names in urls for ModelEndpoints such as /ajax/my_app/mymodel/{pk}/tags/add.json must not be capitalised or the endpoint_loader will fail.

eg if you posted to /ajax/my_app/Mymodel/{pk}/tags/add.json then hasattr(my_app.endpoints, 'Mymodel') will return true because endpoints imports Mymodel to create the ModelEndpoint, but this will make the endpoint_loader think it's an ad-hoc endpoint instead. From endpoint_loader:

if hasattr(module, model):
    # This is an ad-hoc endpoint
    endpoint = getattr(module, model)

It will then fail when it tries to serialize the model object via data = endpoint(request)

joestump commented 13 years ago

Ah, interesting. You want to fork and add to the docs? :)

On Aug 8, 2011, at 3:11 AM, MattFisher wrote:

I think it needs to be made clear that the model names in urls for ModelEndpoints such as /ajax/my_app/mymodel/{pk}/tags/add.json must not be capitalised or the endpoint_loader will fail.

eg if you posted to /ajax/my_app/Mymodel/{pk}/tags/add.json then hasattr(my_app.endpoints, 'Mymodel') will return true because endpoints imports Mymodel to create the ModelEndpoint, but this will make the endpoint_loader think it's an ad-hoc endpoint instead. From endpoint_loader:

if hasattr(module, model):
   # This is an ad-hoc endpoint
   endpoint = getattr(module, model)

It will then fail when it tries to serialize the model object via data = endpoint(request)

Reply to this email directly or view it on GitHub: https://github.com/joestump/django-ajax/issues/15