• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Axiologue / DjangoRestMultipleModels / 7
98%

Build:
DEFAULT BRANCH: master
Ran 21 Sep 2016 08:10PM UTC
Jobs 5
Files 5
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
7

Pull #14

travis-ci

web-flow
Add "objectify" option

I think it would be nice if there was option to get back an object instead of a list.

Example:
Let's say you running a food delivery company and you save in the DB the details of "meals" and "deliveries".
The result would look something like this:
```
[
    {
        "meals": [
            {
                "id": 1,
                "name": "meal1",
                "description": "description of meal1",
                "price": 200,
            },
            {
                "id": 2,
                "name": "meal2",
                "description": "description of meal2",
                "price": 250,
            }
        ]
    },
    {
        "deliveries": [
            {
                "id": 1,
                "address": "Somewhere",
            },
            {
                "id": 2,
                "address": "Somewhere else",
            }
        ]
   }
]
```
With this kind of result you can't do something like:
```
axios.get(url).then(response => {
    alert(response.data.meals)
})
```
Because response.data is an array.
Instead you will have to iterate through the result and look for an object that has a key "meals".
It's a shame because this is a very common use.

In order to solve it I added is a little flag called "objectify" (a little like "flat").
In case objectify=True you will get something like this:
```
{
    "meals": [
            {
                "id": 1,
                "name": "meal1",
                "description": "description of meal1",
                "price": 200,
            },
            {
                "id": 2,
                "name": "meal2",
                "description": "description of meal2",
                "price": 250,
            }
        ]
        "deliveries": [
            {
                "id": 1,
                "address": "Somewhere",
            },
            {
                "id": 2,
                "address": "Somewhere else",
            }
        ]
}
```
Now you can easily do:
```
axios.get(url).then(response => {
    alert(response.data.meals)
})
```
Pull Request #14: Add "objectify" option

369 of 377 relevant lines covered (97.88%)

4.89 hits per line

Uncovered Existing Lines

Lines Coverage ∆ File
4
100.0
drf_multiple_model/mixins.py
Jobs
ID Job ID Ran Files Coverage
2 7.2 (DJANGO="Django<1.9") 21 Sep 2016 08:10PM UTC 0
97.88
Travis Job 7.2
4 7.4 (DJANGO="Django<1.9") 21 Sep 2016 08:10PM UTC 0
97.88
Travis Job 7.4
5 7.5 (DJANGO="Django<1.10") 21 Sep 2016 08:10PM UTC 0
97.88
Travis Job 7.5
6 7.6 (DJANGO="Django<1.9") 21 Sep 2016 08:12PM UTC 0
97.88
Travis Job 7.6
7 7.7 (DJANGO="Django<1.10") 21 Sep 2016 08:11PM UTC 0
97.88
Travis Job 7.7
Source Files on build 7
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #7
  • Pull Request #14
  • PR Base - master (#6)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc