Skip to main content

Django-inspect-model

Build Status

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

Release files for django-inspect-model 0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-inspect-model 0.7
File Size Uploaded
django-inspect-model-0.7.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-inspect-model 0.7
File Interpreter ABI Platform
django_inspect_model-0.7-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.1 kB

Release files / django-inspect-model-0.7.tar.gz

Download URL django-inspect-model-0.7.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c33947603694fe75402f4545ba1aec5bd2dfcd76c9c005841226a782309c65b6
BLAKE2b-256 checksum
How to use checksums
74d40900605275f7450d98b5c10efdcd7eace8ead65ab1f593d0183c3718ca65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_inspect_model-0.7-py2.py3-none-any.whl

Download URL django_inspect_model-0.7-py2.py3-none-any.whl
Size 8.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
feeb6d38cdd22ef268b074819da94209330fd0e7aa543ff94be9035c7e2230fd
BLAKE2b-256 checksum
How to use checksums
f13f1c5e2d15d4d16973aa055fea95bb0c9e29327f976196b13afc7c21350672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.7 This release

2 release files

0.6

2 release files

0.5

2 release files

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page