Learn Django
View Contact - Create URL
Users should be able to view a contact's details by accessing the '/contact/
Step 1: Create Contacts Detail URL
The first step is to create the contact detail URL configuration. This configuration will be stored in the url config file of the app. Follow these steps to set it up.
- Create the file
/.../crmeasy/crmapp/contacts/urls.py
- Open it and type in the following
1 2 3 4 5 6 7
from django.conf.urls import patterns, url contact_urls = patterns('', url(r'^$', 'crmapp.contacts.views.contact_detail', name="contact_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 contacts.urls import contact_urls
Then add the following code to the URL configuration (below the 'Contact related URLS' comment):
1 2
# Contact related URLS url(r'^contact/(?P<uuid>[\w-]+)/', include(contact_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 contact detail url"