![]() |
In this article, we will guide you through the process of creating a comprehensive Movie Recommendation System with the added functionality of user authentication. By incorporating a login system, users can create accounts, personalize their preferences, and access movie recommendations tailored to their tastes. This combination of user authentication and movie recommendations enhances the overall user experience, making the system more engaging and user-friendly. Movie Recommendation System Using DjangoThe initial step in our project involves setting up a user authentication system. Django, a high-level Python web framework, provides built-in features for handling user authentication seamlessly. By utilizing Django’s authentication views and forms, users can easily register, log in, and manage their accounts. To install Django follow these steps. Starting the Project FolderTo start the project use this command django-admin startproject core To start the app use this command python manage.py startapp book
Now add this app to the ‘settings.py’ INSTALLED_APPS = [ File Structure ![]() file structure Setting Necessary Filesmodels.py : In This Django code defines two models: `Emenitites` and `Movie`. The `Emenitites` model represents movie-related amenities with a single field for the amenity name. The `Movie` model represents individual movies with fields for the name, description, image URL, price, and a many-to-many relationship with amenities. This structure enables the creation of a Movie Recommendation System where movies can be associated with various amenities, offering a foundation for personalized recommendations based on user preferences and selected amenities. Python3
Views.py : In this Django code implements a Movie Recommendation System with user authentication. The `home` view displays a list of amenities, and the `api_movies` view provides movie data with filtering options. User authentication is managed by the `login_page`, `register_page`, and `custom_logout` views. The `login_required` decorator ensures authentication for the `home` and `api_movies` views. The system utilizes Django models for movie-related entities and user authentication, enhancing its functionality. Python3
Creating GUIbase.html : In this HTML template establishes the structure for a Movie Recommendation System webpage using Bootstrap and Font Awesome. It includes a navigation bar with links for “Home,” “Login,” and “Register.” The main content is encapsulated in a customizable block. The page title is set to “Movie Recommendation System,” contributing to a visually appealing layout. HTML
login.html : In this file the below code maintains the structure of a login page that extends the base template. It includes form elements for username and password, along with Bootstrap styling. The unnecessary spaces and redundant styles are removed for conciseness. Python3
register.html : The below HTML code extends a base template to create a registration page. It features a form for username and password, displays success messages, and includes a link to the login page. The styling uses Bootstrap classes and custom CSS for a visually appealing layout, including a shadowed card and themed buttons. Python3
home.html : This HTML code creates a Movie Recommendation System web page using Django. It uses Materialize CSS and jQuery for styling and functionality. Users can select movie preferences (amenities and price) to dynamically fetch and display movie recommendations from the Django API. The layout is clean, featuring a GeeksforGeeks header and a logout option. HTML
admin.py:Here we are registering our models. Python3
Deployement of the ProjectRun these commands to apply the migrations: python3 manage.py makemigrations Run the server with the help of following command: python3 manage.py runserver
Output: ![]() register.html ![]() login.html ![]() home.html Video demonstration |
Reffered: https://www.geeksforgeeks.org
Django |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |