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.

Project description

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

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.0 (2018-08-28)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-related-models, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size django_related_models-0.1.0-py2.py3-none-any.whl (5.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-related-models-0.1.0.tar.gz (16.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page