Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/OpenClassrooms-Student-Center/Python-OC-Lettings-FR/llms.txt

Use this file to discover all available pages before exploring further.

Orange County Lettings defines its URL routing in oc_lettings_site/urls.py. All routes are mapped to view functions in views.py.

URL patterns

from django.contrib import admin
from django.urls import path

from . import views

urlpatterns = [
    path('', views.index, name='index'),
    path('lettings/', views.lettings_index, name='lettings_index'),
    path('lettings/<int:letting_id>/', views.letting, name='letting'),
    path('profiles/', views.profiles_index, name='profiles_index'),
    path('profiles/<str:username>/', views.profile, name='profile'),
    path('admin/', admin.site.urls),
]

Route reference

URL patternView functionURL nameDescription
/views.indexindexHome page
/lettings/views.lettings_indexlettings_indexLists all lettings
/lettings/<int:letting_id>/views.lettinglettingSingle letting detail
/profiles/views.profiles_indexprofiles_indexLists all profiles
/profiles/<str:username>/views.profileprofileSingle profile detail
/admin/Django adminDjango admin panel

Path converters

Django’s path() function supports typed URL parameters called path converters:
  • <int:letting_id> — captures a positive integer from the URL segment and passes it to the view as letting_id. Used in /lettings/<int:letting_id>/.
  • <str:username> — captures any non-empty string (excluding /) and passes it to the view as username. Used in /profiles/<str:username>/.

Named URLs in templates

Named URL patterns allow templates to generate URLs without hardcoding paths. Django’s {% url %} template tag resolves a named route to its current URL. Link to the lettings list from any template:
<a href="{% url 'lettings_index' %}">Lettings</a>
Link to a specific letting detail page, passing the letting’s id as an argument:
<a href="{% url 'letting' letting_id=letting.id %}">{{ letting.title }}</a>
Link to a specific profile detail page, passing the username as an argument:
<a href="{% url 'profile' username=profile.user.username %}">{{ profile.user.username }}</a>
ROOT_URLCONF is set to oc_lettings_site.urls in settings.py, which tells Django to load this file as the top-level URL configuration for the application.

Build docs developers (and LLMs) love