On Wed, 2007-11-14 at 02:07 +0000, Tomek wrote: > Hi All, > > I am using "django_restapi" (http://code.google.com/p/django-rest- > interface/) to quickly gain access in a RESTful way to some tables in > a legacy database. I am only really interested in reading the records > and sending them back in XML or JSON format. I don't need to create, > update or delete any records. > > So far "django_restapi" works great for the simple case of accessing > individual models. But as soon as I try to do anything more useful I > get stuck. I have an old Perl script which accesses the same legacy > database and using a custom SQL query returns a bunch of records. I > would like to add a new model to my RESTful Django app which would > perform the equivalent query. I don't want to do it in a view because > then I will have to write all that boiler-plate code that's already in > "django_restapi", such as handling errors, returning correctly > formatted and serialised query sets etc.
The error handling and serialisation stuff in django-restapi is just using Django's regular code. It's important to keep in mind that a framework like restapi isn't going to be suitable for all cases. Modelling things in a "REST" style is simply too general to be able to be made totally formulaic. At times, you'll find working with Django directly is no more complicated and would be the preferred approach. Don't get twisted into knots tyring to do something one way when it's not making things any easier. I don't understand what you mean when you say you want to create a model for a custom SQL query. Since model's don't correspond directly to queries, the statement doesn't quite make sense. Perhaps a short example would clarify what you're asking about? > I want to write a dynamic model which doesn't correspond to any real > table and plug it straight into "django_restapi". The dynamic nature > of this model would come from the fact that it has to dynamically > compute query sets using custom SQL statements. I don't seem to be > able to find anything relevant to this problem anywhere. It sounds like a custom model manager will do what you want (see the model-api documentation), but, again, without an example, it's hard to say. Regards, Malcolm -- Save the whales. Collect the whole set. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---