What is Frappe web framework and the reasons to choose over Django
What is Frappe framework?
Key features of Frappe are:
- MVC framework based on Werkzeug
- ORM support
- Auto generated UI based on Meta-data
- Provides users, user roles and permissions
- Comes with the scheduler (python RQ) for background jobs
- Real-time notifications and web sockets
- Templating based on Jinja
- Multi-language support comes out of the box.
- Re-usable apps
- Rest API
- Batteries included (email, OAUTH support, reports, payment gateway, chat)
When to use Frappe?
- To build ERP systems since they do not recommend not to use outside the ERP.
- Building the administration and business applications for small/medium-sized products.
- Internal tools and portals used for reports
When to choose Frappe over Django?
- To solve the business applications meant a set of features which come by default with Frappe.
- A lot of features comes by default in Frappe helps us not to re-invent the wheel when building the products that use scheduler and auto report generation.
The main key point to understand when looking at Frappe is how the database is declared and model-view building happens internally. It uses meta-data based declaration which is just a JSON file that creates the tables and fields in the database based on it and gives a rich user interface with its bindings to its corresponding database fields.
- Database: MariaDB and Postgres(no support for ERPnext)
- Webserver: Werkzeug
- Templating: Jinja
- Job Queues: Python RQ(Scheduler)
- CSS Framework: Bootstrap 3
- Caching: Redis(In-memory)
- Realtime: NodeJS + Socketio.js
- Webserver: gunicorn + NGINX (Production)
- Process Manager (Production): supervisord
- Process Manager (Develop): Honcho
- Command Line: Bench
- Wkhtmltopdf : Command line tool to process HTML in PDF (report generation)
Reasons to choose Frappe:
- To build ERP/ business product
- Ability to customize the architecture
- Additional components as a default packages(emails, oath)
Relate Frappe with Django(setup):
Initialize the project
django-admin startproject django-project
bench init frappe-bench
Creating a new app in the project
python manage.py startapp custom_app
bench new-app custom_app
Start the server
python manage.py runserver
The admin interface in Frappe is called Desk which is generated using the meta-data(JSON).DocTypes and automatically builds list views, form views, report views, etc for your DocTypes and allows the option to set permissions for users to view/modify it.
- DocType: DocType is responsible for models and views in Frappe, which holds the reason to be called as meta-based. It stores all the fields and its types of databases in JSON data. In short, it describes models and views.
Supports many-to-one relationship to the fields in the form of child DocType to a field.
It is a python package and should be under the directory
apps in the
frappe-bench directory. Each app should have an entry in
apps.txt file just like in Django settinngs.py to be considered.
4.Links: The fields between two tables can be mapped with each other through Links and we need to specify the target fields from the parent table. This acts more of a foreign key reference.
Note: Remember that Link fields are not automatically set as Foreign Keys in the MariaDB database, because that will implicitly index the column. This may not be optimum hence the Foreign Key validation is done by the Framework.
Report generation works out of the box for Frappe without the need for the developer to work on it. It also suppors the scheduler to generate the reports and can be exported in many formats including PDF, XLSX.