Skip to main content

A library designed such that, when provided with a model instance it will return a QuerySet for the rows that are associated with that model instance. It also works well with GenericForeignKey objects.

>>> eminem = Artist.objects.filter(stage_name='Eminem').first()
>>> list(get_related_objects(eminem))
[<Albums: Kamikaze>, <Awards: Grammy>, <Cars: Audi R8 Spyder>]

>>> get_related_objects_mapping(eminem)
{<django.db.models.fields.related.ForeignKey: artist>: set([<Albums: Kamikaze>]),
<django.db.models.fields.related.ForeignKey: artist>: set([<Awards: grammy>]),
<django.contrib.contenttypes.fields.GenericForeignKey object at 0x106ff1f50>: set([<Cars: Audi R8 Spyder>])}

Installation

pip install django-related-models

Documentation

https://django-related-models.readthedocs.io/

Development

The tests are run via tox, which you would need to install (if you don’t already have it).

  • To get tox just:

    pip install tox
  • To run the all tests run:

    tox

Changelog

0.1.1 (2020-05-01)

  • Updated tests for latest versions of Django and Python.

0.1.0 (2018-08-28)

  • First release on PyPI.

Metadata

Release files for django-related-models 0.1.1

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-related-models 0.1.1
File Size Uploaded
django-related-models-0.1.1.tar.gz 15.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-related-models 0.1.1
File Interpreter ABI Platform
django_related_models-0.1.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 22.0 kB

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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