Closed lsemel closed 13 years ago
I recently broke that out into encoders.py, which might have some of the answers you're looking for. (I agree philosophically with you.)
How would you use this? I tried importing encoder
and calling encoder.encode(all_people)
, but get an error "'QuerySet' object has no attribute '_meta'
I made a commit in my fork that enables these to be called standalone, and added a test: https://github.com/lsemel/django-ajax/commit/7738c3bc571fc1871f7b50da6cb3626872cdeed6
I didn't see tests for model endpoints, so wasn't sure how to make sure this didn't break anything.
Sweet, this is pretty close to what I was going to implement. I'm going to recommend that I close this ticket and we move the discussion over to an official Pull Request with the commit you have above. How's that sound?
Sure, sending pull request now
See https://github.com/joestump/django-ajax/pull/10 for more if you're following along at home.
Why not allow them to be imported directly? I have an endpoint that looks like this, and it seems to be a lot of rigamarole to have to subclass BaseEndpoint just so I can get access to the encoding function.