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
['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.items
['comment', 'content_type', 'flags', 'id', 'ip_address', 'is_public',
'is_removed', 'object_pk', 'site', 'submit_date', 'user', 'user_email',
'user_name', 'user_url', '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.4.tar.gz (5.4 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-inspect-model-0.4.tar.gz
Algorithm Hash digest
SHA256 3e3fd96fe0e23e1fb9503546850c2e8ce8f2c3c72461c10c32f01ddb7087593e
MD5 381cf1a9ab8ad7f5c7def16ae7af7b9b
BLAKE2b-256 f6d264b18f99aae658990348da2a3df4f6e853a507c02e4fd34a3f99db850184

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