Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/20tab/twentytab-model-to-bidimensional
A django app that returns a bidimensional representation of a given model and queryset following foreign keys recursively
https://github.com/20tab/twentytab-model-to-bidimensional
Last synced: 21 days ago
JSON representation
A django app that returns a bidimensional representation of a given model and queryset following foreign keys recursively
- Host: GitHub
- URL: https://github.com/20tab/twentytab-model-to-bidimensional
- Owner: 20tab
- License: mit
- Created: 2014-06-04T11:33:04.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-06-04T15:58:42.000Z (over 10 years ago)
- Last Synced: 2024-11-15T16:38:35.996Z (about 1 month ago)
- Language: Python
- Size: 164 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
twentytab-model-to-bidimensional
================================A django app that returns a bidimensional representation of a given model and queryset following foreign keys recursively
**It doesn't work with many-to-many fields yet**
## Installation
Use the following command: pip install twentytab-model-to-bidimensional
## Usage
```py
from django.db import modelsclass Foo(models.Model):
name = models.CharField(max_length=250)class Bar(models.Model):
foo = models.ForeignKey(Foo)
name = models.CharField(max_length=250)```
```py
>>> from bidimensional import Bidimensional
>>> from myapp.models import Bar
>>> b = Bidimensional(Bar, depth=-1, queryset=Bar.objects.all())
>>> b.headers()
[u'id', u'name', u'foo__id', u'foo__name']
>>> b.items()
[{u'foo__id': 1, u'id': 1, u'foo__name': u'foo 1', u'name': u'bar 1'}, {u'foo__id': 2, u'id': 2, u'foo__name': u'foo 2', u'name': u'bar 2'}]
```The results can be used to create a table like this example:
![ScreenShot](https://raw.github.com/20tab/twentytab-model-to-bidimensional/master/screenshot.png)