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.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.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9feb08ef83617568622778d5fec74b0a1f4dbb1123ec163982331d7f8b50ae26 |
|
MD5 | 79b9052c06b74fcd26bd0a49fdbdbca0 |
|
BLAKE2b-256 | c3bd8c4539fe0844c05c6b5aac13b6ec1046ddda92bb913f6636f7ddcfa3f6f4 |
Close
Hashes for django_related_models-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c7178d9d3fc5695457bbc07844e4154b9c96188a5c9708bceeb966f7b54c4d0 |
|
MD5 | 49ab3e6b981c2e319ef36aa33100d498 |
|
BLAKE2b-256 | f8f7a3242ea0af23101164339458f0b3a77324d7ca0ddbd1c2b1a5549601e543 |