Use this file to discover all available pages before exploring further.
DocTypes are the foundation of Frappe’s metadata-driven architecture. A DocType defines the structure, behavior, and properties of a document type in your application.
DocTypes contain field definitions (DocFields) that specify the data structure:
# Get all fieldsfields = meta.fields# Get specific fieldemail_field = meta.get_field('email')print(email_field.fieldtype) # 'Data'print(email_field.label) # 'Email'print(email_field.reqd) # 1 (required)# Get fields by typelink_fields = meta.get_link_fields()table_fields = meta.get_table_fields()
The Meta class provides methods to inspect and work with DocType metadata:
from frappe.model.meta import get_metameta = get_meta('Sales Order')# Check if field existsif meta.has_field('customer'): print("Field exists")# Get field labellabel = meta.get_label('customer') # "Customer"# Get title fieldtitle_field = meta.get_title_field() # Field used as document title# Get valid columns (database columns)valid_columns = meta.get_valid_columns()# Get search fieldssearch_fields = meta.get_search_fields() # Fields used in search
Single DocTypes have only one record (e.g., System Settings):
meta = frappe.get_meta('System Settings')print(meta.issingle) # True# Single DocTypes use the name of the DocType as the document namedoc = frappe.get_doc('System Settings', 'System Settings')
Child DocTypes are used in table fields for one-to-many relationships:
meta = frappe.get_meta('Sales Order Item')print(meta.istable) # True# Access child tables through parentso = frappe.get_doc('Sales Order', 'SO-0001')for item in so.items: # 'items' is a Table field print(item.item_code, item.qty)
meta = frappe.get_meta('Sales Order')# AutoName options:# - 'field:fieldname' - Use a field value as name# - 'naming_series:' - Use a naming series (SO-.####)# - 'Prompt' - User enters the name# - 'autoname:EXPR' - Custom expression# - '[field]' - Use specific fieldprint(meta.autoname) # 'naming_series:'# Get naming series optionsseries_options = meta.get_naming_series_options()# Returns: ['SO-.YYYY.-', 'SO-.####.-']