Frappe is more than just the framework behind ERPNext. It’s a full-stack web framework that lets you build database-driven applications incredibly fast. This guide walks you through building a simple Task Manager app from scratch.
Pre-requisites
Frappe Bench installed (see our Frappe setup guide)
A working Frappe site
Basic Python and JavaScript knowledge
STEP 1 Create the App
cd frappe-bench
bench new-app task_managerAnswer the prompts (app name, description, etc). Then install it on your site:
bench --site mysite.local install-app task_managerSTEP 2 Create a Doctype
Go to http://mysite.local:8000 and search for “Doctype” > New Doctype.
Name: Task Item
Module: Task Manager
Fields:
- title (Data, Required)
- description (Text Editor)
- status (Select: Open, In Progress, Completed, Cancelled)
- priority (Select: Low, Medium, High, Urgent)
- assigned_to (Link: User)
- due_date (Date)
Naming: autoincrement
Sort Field: modified
Sort Order: DESCSTEP 3 Add Server Logic
nano apps/task_manager/task_manager/task_manager/doctype/task_item/task_item.pyimport frappe
from frappe.model.document import Document
class TaskItem(Document):
def validate(self):
if self.due_date and self.due_date < frappe.utils.today():
frappe.msgprint("Warning: Due date is in the past")
def on_update(self):
if self.status == "Completed":
frappe.publish_realtime(
"task_completed",
{"task": self.name, "title": self.title}
)STEP 4 Add Client Logic
nano apps/task_manager/task_manager/task_manager/doctype/task_item/task_item.jsfrappe.ui.form.on("Task Item", {
refresh(frm) {
if (frm.doc.status !== "Completed") {
frm.add_custom_button("Mark Complete", () => {
frm.set_value("status", "Completed");
frm.save();
}, "Actions");
}
// Color-code priority
if (frm.doc.priority === "Urgent") {
frm.dashboard.set_headline(
'URGENT TASK'
);
}
}
});STEP 5 Create an API Endpoint
nano apps/task_manager/task_manager/api.pyimport frappe
@frappe.whitelist()
def get_my_tasks(status=None):
filters = {"assigned_to": frappe.session.user}
if status:
filters["status"] = status
tasks = frappe.get_all("Task Item",
filters=filters,
fields=["name", "title", "status", "priority", "due_date"],
order_by="due_date asc"
)
return tasksCall it from anywhere:
curl http://mysite.local:8000/api/method/task_manager.api.get_my_tasks
-H "Authorization: token api_key:api_secret"STEP 6 Build and Run
bench --site mysite.local migrate
bench --site mysite.local clear-cache
bench build
bench startYou now have a working web application with a database, REST API, real-time updates, user permissions, and a complete UI — all built in about 30 minutes. That's the power of the Frappe framework.
Comments
Join the discussion. Got a question, found an issue, or want to share your experience?