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
Documentation
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-related-models-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96b8fbe7b3dbf2de8e866b9132c9c14721351c90c6e5dd0f1063300061645476 |
|
MD5 | 42aaa362ae80d1d5e6911a9bd3a73c8e |
|
BLAKE2b-256 | c20703750df92d676a422c5cbb025cda53b06475585324b8e1c583a4e6f04b0a |
Close
Hashes for django_related_models-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2389891e246ee8b6009255716c7b35d508c9cd0fea081287e6e8a57ff15578a1 |
|
MD5 | 3993762fd988907ccfc692cd6be8dec9 |
|
BLAKE2b-256 | 649c2582574f1ea2b7e5c5a1d5bb4ce2eb1b5e87ddf4142f7b94ba22fabcf72a |