# Expression detail page

## In this section

* Displaying the details and content of an expression

## Expression detail page

Now let's add an expression detail page that shows the content of a single expression of a work.

Add a new view to your `views.py`:

{% code title="views.py" %}

```python
from django.views.generic import ListView, DetailView
from .models import Work, Expression

class WorkListView(ListView):
    model = Work
    
class ExpressionDetailView(DetailView):
    model = Expression
    slug_field = 'frbr_uri'
    slug_url_kwarg = 'frbr_uri'
```

{% endcode %}

Add the new view to your `urls.py`:

{% code title="urls.py" %}

```python
from django.urls import path
from reader.views import *

urlpatterns = [
    path('', WorkListView.as_view(), name="home"),
    # the FRBR URI starts with a /
    path('expression<path:frbr_uri>', ExpressionDetailView.as_view(), name="expression"),
]
```

{% endcode %}

Now create a template called `templates/reader/expression_detail.html`. We'll start with just the title and the expression content.

{% code title="expression\_detail.html" %}

```html
<html>
<head>
  <title>{{ expression.title }}</title>
</head>
<body>
  <a href="{% url 'home' %}">Home</a>
  
  <h1>{{ expression.title }}</h1>
  
  <div>{{ expression.content|safe }}</div>
</body>
```

{% endcode %}

{% hint style="info" %}
If there are other expressions on the same work (different language or date), how would the user find them?
{% endhint %}

If you visit an expression detail page, you'll see the title and some ugly content. In the next section we'll add formatting to the content.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.laws.africa/tutorial/module-1-build-a-legislation-reader/expression-detail-page.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
