Getting generic views to support “fake” models| by jpic | python django crudlfap
Sometimes, we need to make views around objects which are not stored in the database. They may be calculated on the fly in python, or come from some data source that’s not the database, or which aggregates several objects in the database.
This is supported out of the box with CRUDLFA+, the modern web framework for Django. All you need to implement is:
- a Model class with what you want in it, just set
delete()like you want in it, if you want create, update and delete views to work,
get_object()like you want in the Router.
This example model from crudlfap_example uses a class attribute in the manager to store the object list in memory. That’s probably not what you want to do in your own project, but that works for the PoC because it demonstrates how to override
This example urls from the same example demonstrates how
And then … well, that’s all ya need, welcome in 2017.
Jamesy aka jpic