Learn Django

View Comm - Create URL

Users will be able to view the details of communication by visiting '/comm//' in a browser. This follows the same pattern for all of the resources created so far in this project.

Step 1: Create Communications Detail URL

Follow these steps to configure the communications urls file.

  1. Open /.../crmeasy/crmapp/communications/
  2. Create a file there named urls.py
  3. Open this file and add the below contents
1
2
3
4
5
6
7
8
9
from django.conf.urls import patterns, url

comm_urls = patterns('',

    url(r'^$',
        'crmapp.communications.views.comm_detail', name="comm_detail"
    ),

)

Step 2: Update the Main URL Configuration File

Follow these steps to update the main URL config file.

Open the /.../crmeasy/crmapp/urls.py. First, add this import to the top of the file.

1
from communications.urls import comm_urls

Then add the following code to the URL configuration (below the 'Communication related URLs' comment):

1
2
# Communication related URLs
url(r'^comm/(?P<uuid>[\w-]+)/', include(comm_urls)),

Step 3: 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 URL"

Track your progress with a free account