---
title: "Ask your Django app why a price came out the way it did · Adea"
description: "Adea reads your Django models and pricing and discount logic and explains to sales and support how a price was worked out."
url: https://adea.app/stack/django
---

# Why didn't the customer get the discount? Get the answer with the rule in the code.

Prices, discounts and rules often sit in a views.py or a service that only developers can read. Adea reads it and explains step by step what happened on a specific order.

[Start free](https://adea.app/signup) [See the demo](https://adea.app/demo)

## Why didn't order 10432 get the volume discount?

1. Finding order 10432
2. Reading shop/pricing.py
3. Matching the rule against the order lines

A question asked of a Django system

Why didn't order 10432 get the volume discount?

Adea's answer

The order had 9 items, and the volume discount starts at 10. The discount also only applies to items in the Tools category, and 2 of the items were in Accessories.

## Where the number comes from

The code Adea read `shop/pricing.py:112`

```
def volume_discount(lines):
    eligible = [l for l in lines
                if l.product.category == 'tools']
    if sum(l.qty for l in eligible) >= 10:
        return Decimal('0.08')
```

The query it ran

```
SELECT l.qty, c.name FROM shop_orderline l
JOIN shop_product p ON p.id = l.product_id
JOIN shop_category c ON c.id = p.category_id
WHERE l.order_id = 10432
```

## What you get

### Explains, not just counts

Adea shows the sequence: which lines counted, which rule was hit and why the threshold was not reached. Support can answer the customer right away.

### Understands your ORM

Adea follows relations and managers in the Django models and finds the right tables, even when the names do not look like what you call things.

### The rule can be corrected

If Adea has understood a rule wrongly, a developer corrects it. The fix applies to all future answers.

## How to connect a Django app

Give read access to the repo and to a Postgres read-only user. Adea finds the models itself.

```
CREATE ROLE adea_readonly LOGIN PASSWORD '…';
GRANT SELECT ON ALL TABLES IN SCHEMA public TO adea_readonly;
```

[Read the setup guide](https://adea.app/docs/connect-database)

## Questions about Django

### Does it work with Django REST framework and Celery?

Adea reads the code that decides the rules, whether it lives in views, serializers, services or tasks.

### Can support see the customer's data?

Only the tables and columns you open for their role.

### What about Django admin?

It is not required, but you can have Adea link to the record in admin in the answer.

## Other stacks

[Rails](https://adea.app/stack/rails) [Laravel](https://adea.app/stack/laravel) [Node.js](https://adea.app/stack/node) [Magento](https://adea.app/stack/magento) [WooCommerce](https://adea.app/stack/woocommerce) [Shopware](https://adea.app/stack/shopware) [Solidus](https://adea.app/stack/solidus)

## What do you want to know?

[Start free](https://adea.app/signup) [Book 20 minutes](mailto:hello@adea.app?subject=20%20minutes%20about%20Adea)
