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
=================
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-viewmodels-0.1.0.tar.gz
.
File metadata
- Download URL: django-viewmodels-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aebe1b0a24add8e83e81058494c8338082d628d64200b063d361757a0c65f3a6 |
|
MD5 | 95dd6dd6aaf615a1ddc002322bdac864 |
|
BLAKE2b-256 | ed6213b2feb1bdcc0c3f374d6d52c4a841a4686c45ecaecfeb4ae47955ca4357 |
File details
Details for the file django-viewmodels-0.1.0.linux-i686.tar.gz
.
File metadata
- Download URL: django-viewmodels-0.1.0.linux-i686.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42ed0c3ebc5a9cfc59c1b851397b8ea9f7eba7fe5f8b7c6d48c9fc933834cd34 |
|
MD5 | 9a5bc149c93d04fbb7a05be07aa93d3f |
|
BLAKE2b-256 | ca177e4c1c1c2e7abc0b64fd1fc8da7bb1fe64437f0c65b046b3c5d9ed9bb6af |