Learn Django

View Comm - Create Template

Two templates will be created to display the Communication Details page. The first template is the parent and will allow users to display records on a standalone page. The second template is an item view of the communication record. By breaking them apart like this we can use the second template to inject communication records into any page.

Step 1: Create the Comm_detail.html Template

Follow these steps to create this template.

  1. Navigate to /.../crmeasy/crmapp/templates
  2. Create a folder there named communications/
  3. In this folder create a file named comm_detail.html
  4. Open this file and type in the following code
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{% extends 'base.html' %}
{% block title %}Communication Detail{% endblock title %}

{% block content %}
    <div id="content-container" class="container p-none">
        <ul id="co-list" class="strip-list col-md-12 p-none">
            {% include 'communications/comm_item_view.html' %}
        </ul>
    </div>
{% endblock %}

Step 2: Create the Communications Item Template

Follow these steps to create the communications item template.

  1. Navigate to /.../crmeasy/crmapp/templates/communications
  2. Create a file named comm_item_view.html and open it
  3. Type in the following code
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<li class="co-item">
    <h5 class="co-item-h">{{ comm.subject }}
        <span>
            {# Comm Delete URL #}
            <a class="cancel comm-control" 
               href=""></a>
            {# Comm Edit URL #}
            <a class="pen comm-control comm-edit" 
               href=""></a>
        </span>
    </h5>
    <p class="co-item-date">on {{ comm.date }}</p>
    <p>{{ comm.notes }}</p>
</li>

Commit Changes

Execute these commands to commit your changes in Git.

1
2
3
4
5
# add files
(venv)$ git add .

# commit files
(venv)$ git commit -m "created the communication detail template"

Track your progress with a free account