Learn Django

View Account - Create URL

The account detail page can be accessed at the /account/<uuid>/ URL, where <uuid> is the actual uuid for the account. When this URL is accessed, a page will display showing the account details, such as its name, address, and description. Later on this page will also show related contacts and communications.

Step 1: Create Accounts Detail URL

The first step is to create the account detail URL configuration. This configuration will be stored in the url config file of the app. Follow these steps to set it up.

  1. Open /.../crmeasy/crmapp/accounts/
  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
from django.conf.urls import patterns, url

account_urls = patterns('',

    url(r'^$',
        'crmapp.accounts.views.account_detail', name='account_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 accounts.urls import account_urls

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

1
2
3
4
5
# Account related URLs
url(r'^account/list/$',
    AccountList.as_view(), name='account_list'
),
url(r'^account/(?P<uuid>[\w-]+)/', include(account_urls)),
Track your progress with a free account