Model inspection for Django
Project description
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’
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.
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 ['id', 'content_type', 'object_pk', 'site', 'user', 'user_name', 'user_email', 'user_url', 'comment', 'submit_date', 'ip_address', 'is_public', 'is_removed'] >>> im.attributes [] >>> im.methods ['get_as_text', 'get_content_object_url'] >>> im.items ['id', 'content_type', 'object_pk', 'site', 'user', 'user_name', 'user_email', 'user_url', 'comment', 'submit_date', 'ip_address', 'is_public', 'is_removed', 'get_as_text', 'get_content_object_url']
Authors: see AUTHORS
Licence: BSD
Compatibility: Django 1.3+
Requirements: none
Documentation: http://django-inspect-model.readthedocs.org/en/latest/
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
File details
Details for the file django-inspect-model-0.2.tar.gz
.
File metadata
- Download URL: django-inspect-model-0.2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebf8339a8e6053be66b3dcf9a9d7e3f06b657b74902271fe6c4095a3801feaad |
|
MD5 | 7fb3d5f63d203945e26f2f47ef6fd1c6 |
|
BLAKE2b-256 | 644c89fabca1718bbc40746141df599ebd625bfe27f6c7f86b72eceab6b5e3e5 |