This is a Django project for the Little Lemon Restaurant website.
The Little Lemon Restaurant website is built using Django for the back-end, MySQL as the database, and JavaScript for handling form components of the template. HTML with supportive stylesheets are already added as part of the starter code.
The project directory is named littlelemon and the app is named restaurant.
To get started with the project, follow these steps:
- Install
pipenvif you haven't already. - Create a virtual environment using
pipenv. - Activate the virtual environment.
- Install the project dependencies using
pipenv. - Set up the MySQL database and configure the Django settings accordingly.
- Run the Django development server.
- Menu
- Booking
-
def home(request)
""" Renders the home page.
Args: request: The HTTP request object.
Returns: The rendered index.html template. """
-
def about(request): """ Renders the about.html template.
Parameters:
- request: The HTTP request object.
Returns:
- The rendered about.html template. """
-
def book(request): """ View function for booking a table.
Args: request (HttpRequest): The HTTP request object.
Returns: HttpResponse: The HTTP response object.
"""
-
def reservations(request): """ View function for handling reservations.
Args: request (HttpRequest): The HTTP request object.
Returns: HttpResponse: The HTTP response object containing the rendered bookings.html template. """
-
def bookings(request): """ View function for displaying bookings.
Parameters:
- request: The HTTP request object.
Returns:
- A rendered HTML template with the bookings data. """
-
def menu(request): """ Renders the menu page with the menu data.
Args: request (HttpRequest): The HTTP request object.
Returns: HttpResponse: The rendered menu page. """
-
def display_menu_item(request, pk=None): """ Display a menu item based on the given primary key (pk).
Args: request (HttpRequest): The HTTP request object. pk (int, optional): The primary key of the menu item. Defaults to None.
Returns: HttpResponse: The rendered HTML template with the menu item data. """
-
def bookings(request): """ View function for handling bookings.
Args: request (HttpRequest): The HTTP request object.
Returns: HttpResponse: The HTTP response object containing booking information in JSON format. """
- Booking Form, inheriting from the ModelForm it uses as it Model the Booking Model and does some client-side validations and set up the necessary Form DB attibutes
-
cd littlelemon
-
pipenv shell
-
pipenv install
-
python manage.py makemigrations
-
python manage.py migrate
-
python manage.py runserver
- MySQL Instance
- Django-specific requirements can be found in the requirements.txt file.