Code Reference

This section documents all classes, functions, and methods available in the OC Lettings Site application.

Lettings Application

The lettings app manages rental properties and their addresses.

Models

class Address(*args, **kwargs)

Represents a physical address linked to a letting.

Stores structured data for the street, city, and postal information. Each address is unique and associated with a single letting.

number

Street number (max 4 digits)

street

Street name (up to 64 characters)

city

City name (up to 64 characters)

state

Two-letter state abbreviation (e.g., ‘CA’)

zip_code

Postal code (max 5 digits)

country_iso_code

Three-letter country code (ISO 3166-1 alpha-3)

__str__()

Returns a readable string representation of the address.

Return type:

str

class Letting(*args, **kwargs)

Represents a property available for rent.

Each letting is linked to a unique address and has a descriptive title to identify the property in the interface.

title

Name or label of the property

address

One-to-one relationship to the property’s address

__str__()

Returns a readable string representation of the letting.

Return type:

str

Views

index(request)

Display a list of all lettings.

Parameters:

request (HttpRequest) – The HTTP request sent by the user.

Returns:

The rendered lettings index page.

Return type:

HttpResponse

letting(request, letting_id)

Display a specific letting.

Parameters:
  • request (HttpRequest) – The HTTP request sent by the user.

  • letting_id (int) – The ID of the letting to display.

Returns:

The rendered HTML response for the letting detail page.

Return type:

HttpResponse

Profiles Application

The profiles app manages user profiles with additional information.

Models

class Profile(*args, **kwargs)

Profile model that extends the built-in User model with additional information like favorite city.

user

Link to the Django User model

favorite_city

User’s favorite city (optional)

__str__()

Return the username associated with this profile.

Returns:

Username of the linked user.

Return type:

str

Views

index(request)

Display a list of all profiles.

Parameters:

request (HttpRequest) – The request object.

Returns:

The rendered profiles index page.

Return type:

HttpResponse

profile(request, username)

Display a specific user profile.

Parameters:
  • request (HttpRequest) – The HTTP request sent by the user.

  • username (str) – The username of the profile to display.

Returns:

The rendered HTML response for the profile detail page.

Return type:

HttpResponse

Main Site (oc_lettings_site)

Views

index(request)

Display the home page of the Holiday Homes website.

Parameters:

request (HttpRequest) – The HTTP request sent by the user.

Returns:

The rendered HTML response of the home page.

Return type:

HttpResponse

custom_404(request, exception)

Custom 404 error handler when the urls schema is not parameterized.

Parameters:
  • request (HttpRequest) – The HTTP request sent by the user.

  • exception – The exception that triggered the 404 error.

Returns:

The rendered HTML response for the 404 error page.

Return type:

HttpResponse

custom_500(request)

Custom 500 error handler.

Parameters:

request (HttpRequest) – The HTTP request sent by the user.

Returns:

The rendered HTML response for the 500 error page.

Return type:

HttpResponse