From the course: Advanced Python: Practical Database Examples

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Develop add functionality to add a task

Develop add functionality to add a task - Python Tutorial

From the course: Advanced Python: Practical Database Examples

Develop add functionality to add a task

- [Instructor] Let's create some more functionality that lets the user add tasks to their project. We've already written the routes, so now we just need to read in the data from the request and feed it into the database. In our project-tasks.html, we named the user's input task name, so that's how we'll access it in the request form in our app.py. We'll want to add some error checking here just like we did with add_project. We'll make sure the user enters a task name. If the user entered a description, we'll create a new task and add it to the database. Since the URL contains the project_id, we can use it to create the task. We'll just pass it in. After saving the data or lack thereof if the description was empty, we'll want to redirect to the individual project page. This means we'll redirect to show tasks and we'll feed in our project id. Of course, we aren't done yet. We still need to modify the project-tasks.html…

Contents