>
5 bedroom detached house for sale
Charwelton, Daventry, NN11
£600,000
Charwelton, Daventry, NN11
£600,000
Price History
Initial price | £625,000 |
12/06/24 | £600,000 |
Price Change | -4.00% |
Description
```
This is the result I'm getting:
```
A versatile four/five bedroom detached home with countryside views to the rear, this Ideal family property offers a variety of reception rooms and spacious accommodation arranged over two floors. Situated in a unique development in a charming village setting, this home is perfect for families seeking a peaceful rural lifestyle with the convenience of modern amenities.
```
The issue I'm having is that I want to exclude the "Video Viewings" and "Property Details" sections from the output. How can I modify the template to ensure these sections are not included in the final output?
## Answer (1)
You can modify the template to exclude the sections you don't want by using the `exclude` parameter in the `{% for %}` loop. Here's how you can adjust your template to exclude the "Video Viewings" and "Property Details" sections:
```html
{% for property_detail in property.description.property_details %}
{% if not property_detail.name == 'Video Viewings' and not property_detail.name == 'Property Details' %}
{{ property_detail.description|strip }}
{% if not loop.last %}
,
{% endif %}
{% endif %}
{% endfor %}
```
This code iterates over each `property_detail` in the `property.description.property_details` list and checks if the `name` is not 'Video Viewings' or 'Property Details'. If it's not, it outputs the `description`. The `loop.last` check ensures there's no trailing comma if there are multiple items.
Alternatively, if you want to exclude entire sections based on their `name` and you have control over how the `property.description.property_details` list is generated, you could filter out those items before passing the list to the template. Here's an example of how you might do that in your view or controller:
```python
# Assuming `property.description.property_details` is a list of dictionaries
property_details_filtered = [detail for detail in property.description.property_details if detail['name'] not in ['Video Viewings', '