Dynamic Pages

You can render pages dynamically using Jinja templating language. To query data, you can update that context object that you pass to the template.

This can be done by adding a .py file with the same filename (e.g. index.py for index.md) with a get\_context method.

Example

If you want to show a page to see users, make a users.html and users.py file in the www/ folder.

In users.py:

import frappe
def get\_context(context):
 context.users = frappe.get\_list("User", fields=["first\_name", "last\_name"])

In users.html:

### List of Users



{% for user in users %}
 2. {{ user.first\_name }} {{ user.get("last\_name", "") }}

{% endfor %}


Discard
Save

On this page