6

I have an existing Django application with a pretty typical model implementation that's backed by a database. My task is to change this model so that instead of fetching the information from a database, it now fetches it from a service (e.g., via HTTP). Because there is existing code which already makes use of this model, it would be nice to maintain the same model interface so that it continues to behave like a typical Django model.

This raises a few of questions:

  • Is it possible to do this without having to re-write the interface from scratch to make it look like Django's model interface? (This stackoverflow question would seem to suggest otherwise: Django MVC pattern for non database driven models?)

  • Would writing a custom manager for this model be an appropriate approach (or have I misunderstood the role of the manager)?

  • Due to the service-backed nature of the new model, caching will be much more important than before. Is this something that should be implemented at the model level?

1 Answer 1

4

Have a look at django-roa. From the sound of it, it might be exactly what you are looking for.

Sign up to request clarification or add additional context in comments.

4 Comments

This is really neat, and I hadn't seen it before. Unfortunately, the service in question isn't a RESTful one, and I think I'll need the ability to use custom code to perform the work usually done by the database. Still, where one has a RESTful service they can attach their models to, this is pretty nice.
As fate would have it, I no longer need to have a non-database model in real life. As a consequence, this is a much better answer to the question I would rather have been asking anyway. Thanks!
@monkut I updated the link, but it looks like the project isn't maintained anymore, last commit is more than 5 years ago
I was looking for a way to implement a Model without a db backend, and wanted to check this out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.