Skip to main content

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']

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-inspect-model-0.1.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file django-inspect-model-0.1.tar.gz.

File metadata

File hashes

Hashes for django-inspect-model-0.1.tar.gz
Algorithm Hash digest
SHA256 4a5342298d36ca178f3911bf0fdf92a4ab8de1fdcf26168d3aae82f0d7cd4472
MD5 8e4978b93372ce57530cb0c8d5fb8357
BLAKE2b-256 4bb07727d93a84bae0cc8730934f86426a4a21dd97fd3d598aff8cf7bcbd4e0c

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