Model inspection for Django
Project description
Django-inspect-model
Authors: Mathieu Agopian and contributors
Licence: BSD
Compatibility: Python 2.7, Python 3.3, Django 1.3+
Requirements: none
Project URL: https://github.com/magopian/django-inspect-model/
Documentation: http://django-inspect-model.readthedocs.org/en/latest/
Django-inspect-model is a model inspection utility for Django. It allows you to easily list all available “items” on a model, and get their value.
An item is either:
a django field (standard field or relation field)
a standard attribute
a method that only takes one attribute: ‘self’
a property
The code is generic enough to be applied on just any python object, so Django isn’t a requirement. However, it was tailored towards Django models.
Install
Using pip:
pip install django-inspect-model
Usage
Instantiate inspect_model.InspectModel with your model class or instance, and profit.
>>> from django.contrib.comments.models import Comment >>> from inspect_model import InspectModel >>> im = InspectModel(Comment) >>> im.fields ['comment', 'id', 'ip_address', 'is_public', 'is_removed', 'object_pk', 'submit_date', 'user_email', 'user_name', 'user_url'] >>> im.relation_fields ['content_type', 'site', 'user'] >>> im.many_fields ['flags'] >>> im.attributes [] >>> im.methods ['get_as_text', 'get_content_object_url'] >>> im.properties ['email', 'name', 'pk', 'url', 'userinfo'] >>> im.items ['comment', 'content_type', 'email', 'flags', 'get_as_text', 'get_content_object_url', u'id', 'ip_address', 'is_public', 'is_removed', 'name', 'object_pk', 'pk', 'site', 'submit_date', 'url', 'user', 'user_email', 'user_name', 'user_url', 'userinfo']
Hacking
Setup your environment:
git clone https://github.com/magopian/django-inspect-model.git cd django-inspect-model
Hack and run the tests using Tox to test on all the supported python and Django versions:
make test
To build the docs:
make docs
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
Built Distribution
File details
Details for the file django-inspect-model-0.5.tar.gz
.
File metadata
- Download URL: django-inspect-model-0.5.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c375b3bfba635659eb80b9b4f0cbb97c86b373e6e44922f6902b3cabab5c2331 |
|
MD5 | 520d172789b590e8722d45a2d9ea4127 |
|
BLAKE2b-256 | 2627966372845bdbb50e3ff265775608ec76c69bd65043dbf16b55199e9097bb |
File details
Details for the file django_inspect_model-0.5-py2.py3-none-any.whl
.
File metadata
- Download URL: django_inspect_model-0.5-py2.py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4319465c83e02fbe202ec24361dce2b1744d6e6b2462f46e478722e5cb7de826 |
|
MD5 | 7b60a96dc0338fe18c8ff0663636998e |
|
BLAKE2b-256 | 93a7b88368c06cfce3834d1f638177ee841e122aa4cd48a48f36a53247c0e6cb |