1

I'm making a pretty standard AJAXy (well, no XML actually) web page. The browser makes a bunch of API queries that return JSON to run the site. The problem is, I need to add to the API interface each time the page needs to do something new. The new API interface is usually little more than a database query followed by mapping the returned objects to JSON.

What I'd like to do is to get rid of all that server-side duplication and just have the page make database requests itself (using the model interface), but in a way that is safe (i.e. just read only ones). I think this would amount to an interface for constructing Q objects using JSON or something like that, and then send that up to the server, run the query, and return the results. Before I go making my own half-broken architecture for this, I'm wondering if this has already been done well. Also, is this even the best way to go about eliminating this duplication?

Thanks

luqui
  • 59,485
  • 12
  • 145
  • 204

1 Answers1

1

Search multiple fields of django model without 3rd party app

Django SQL OR via filter() & Q(): Dynamic?

Generate a django queryset based on dict keys

Just replace with operator.and_ where appropriate.

Community
  • 1
  • 1
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • Hm, ok, that's basically what I meant when I talked about making my own half-broken architecture, hoping someone had thought through things a bit more. But it'll be pretty simple, looks like a lot of people think that's the right way to go. – luqui May 08 '11 at 02:03