Skip to main content

Class based views for Django with automatic viewmodel rendering

Project description

django-viewmodels
=================

Automatic viewmodel conversion for django class-based views

* import View from djviewmodels.views and use it as a base class
** define viewmodels as a dictionary (key: variable name in context, value: class to replace with)
for automatic conversion of variables in the returned context to viewmodels
** define get, post, put, delete as methods to handle those requests, return a context dictionary
** define init_request as a generic method to handle the beginning of all requests
*** init_request can return a dictionary, whose values will be passed to get/post/whoever
** define template_name or json
*** template_name will cause context dictionaries to be rendered to that template
*** json will cause context dictionaries to be rendered to json

* Automatic viewmodel extension of models:
** define receive_single_instance to have individual viewmodels wrapped around individual models
*** __getattr__ will look inside the instance for fields
*** define fields to specify which fields to allow automatic retrieval of
*** define exclude to exclude fields
** define receive_multiple_instances to have the viewmodel wrap around the whole list
** define receive_custom to receive the list or dictionary as args/kwargs

See the tests for more information and usage
0.1.0: initial release
0.1.1: attempt to fix setup.py issues
0.1.2: attempt to fix setup.py issues
TODO:

* more tests
* better handling of alternative return types (pdf, xml, etc)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-viewmodels-0.1.2.tar.gz (5.2 kB view details)

Uploaded Source

File details

Details for the file django-viewmodels-0.1.2.tar.gz.

File metadata

File hashes

Hashes for django-viewmodels-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bf5f5175e76293762b9b333aaa4210e7730900a6f176df0c9a0c5175c127dc84
MD5 b92c3966aeb7a4b02a41ef78dd79c547
BLAKE2b-256 05cfe583451912fac4e31408d18d5e9afc444a89799087e0ed725d9beb051fb2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page