![]() |
In this article, we will create the Recipe Meal Planner using Django step-by-step. Generally, we will implement the CRUD (Create, Read, Update, Delete) operations, allowing users to add the recipe name, day, and the recipe itself. Additionally, we will establish a login system, requiring users to register and log in before creating the recipe meal planner. Once the user has added all the daily recipe information, they simply need to click a single button. Subsequently, a PDF form will be generated, which the user can save for future reference. Recipe Meal Planner using DjangoHere, we will create the step-by-step Recipe Meal Planner using Django. Create Project FolderTo start the project and app use this command django-admin startproject core Now add this app to the ‘settings.py’ INSTALLED_APPS = [ File Structure Setting Necessary Filesmodels.py: Here, the below code defines a Django model named Python3
views.py: Here, the below code defines a Django application for recipe management, including functionalities for creating, updating, and deleting recipes. It also handles user authentication with login, registration, and logout features. Additionally, there is a basic PDF generation feature for recipes, with the ability to search and filter recipes by day. Python3
Creating GUIlogin.html: Below, HTML code is a concise Bootstrap-based login form for a job portal, featuring input fields for username and password. Success messages are displayed using Bootstrap’s alert, and a link is included for users to create a new account. HTML
register.html: The provided HTML code creates a registration form for a job portal using Bootstrap. It includes input fields for username and password, a registration button, and a link to the login page. Bootstrap’s alert component is utilized for displaying success messages. HTML
recipe.html: The Django template extends a base HTML file and presents a form for adding recipe data. It includes a button to generate a PDF recipe plan and displays a table of existing recipes with options to delete or update. The styling includes a hover effect for link color change. HTML
update_recipe.html: The Django template, extending a base HTML file, displays a form for updating recipe data. It pre-fills fields with existing data and allows users to modify day, recipe name, and description. The styling uses Bootstrap, creating a centered card with a shadow effect. HTML
pdf.html: Below, HTML document defines a Recipe Meal Planner webpage with Bootstrap styling. It includes a table displaying recipe details and a button to generate a PDF using the html2pdf library. The styling features a clean layout with a card container and a green-themed table. JavaScript functionality is added to trigger PDF generation on button click. HTML
base.html: The HTML template serves as a base for Django views, with a dynamic title based on the variable HTML
admin.py :Here we are registering our models. Python3
urls.py : Here, the Django URL patterns include routes for user authentication (login, logout, register), recipe handling (view, update, delete), and a PDF generation endpoint. These paths are associated with corresponding views from the ‘home’ app. Python3
Deployment 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 |
Reffered: https://www.geeksforgeeks.org
Django |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 20 |