I am following through the “Library Management” tutorial provided by “Frappe Framework”. This is the link to the tutorial “https://frappeframework.com/docs/user/en/tutorial”. While doing the tutorial, I came across this page “https://frappeframework.com/docs/user/en/tutorial/portal-pages”.
On the mentioned page there is a section “Web View Pages”. In this section, we are instructed as follows: Go to Article doctype and scroll down to the Web View section.
- Enable Has Web View and Allow Guest to View
- Enter articles in the Route field
- Add fields named Route and Published in the fields table
- Click on Save
However, while following the instructions I am getting errors.
“Is Published Field Must be a mandatory name”
To understand why and from where this error is coming I checked into the frappe code base and found out where it is getting wrong.
def check_is_published_field(meta):
if not meta.is_published_field:
return
if meta.is_published_field not in fieldname_list:
print("xxxxxxxxxxxxxxxxxxxxxxx")
print("meta.is_published_field: ", meta.is_published_field)
print("fieldname_list: ", fieldname_list)
print("xxxxxxxxxxxxxxxxxxxxxxx")
frappe.throw(_("Is Published Field must be a valid fieldname"), InvalidFieldNameError)
I am also printing the values provided in the conditional statement.
13:31:15 web.1 | xxxxxxxxxxxxxxxxxxxxxxx
13:31:15 web.1 | meta.is_published_field: published
13:31:15 web.1 | fieldname_list: [‘article_name’, ‘image’, ‘author’, ‘description’, ‘isbn’, ‘status’, ‘publisher’]
13:31:15 web.1 | xxxxxxxxxxxxxxxxxxxxxxx
So, after debugging it. I understood to satisfy the conditional statement the “Published” field should have value from the fields present inside the “DocType” which are
(‘article_name’, ‘image’, ‘author’, ‘description’, ‘isbn’, ‘status’, ‘publisher’)
When if I do not provide the value in “Is Published” but for the “Route” field as per instruction I get another error.
Field “route” is mandatory for web Views.
and these are the code snippets from the frappe code base and value after debugging respectively
def validate_website(self):
"""Ensure that website generator has field 'route'"""
if self.route:
self.route = self.route.strip("/")
if self.has_web_view:
# route field must be present
if "route" not in [d.fieldname for d in self.fields]:
print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
print("'route' not in [d.fieldname for d in self.fields]: ", "route" not in [d.fieldname for d in self.fields])
print("[d.fieldname for d in self.fields]: ", [d.fieldname for d in self.fields])
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
frappe.throw(_('Field "route" is mandatory for Web Views'), title="Missing Field")
# clear website cache
clear_cache()
13:48:18 web.1 | XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
13:48:18 web.1 | ‘route’ not in [d.fieldname for d in self.fields]: True
13:48:18 web.1 | [d.fieldname for d in self.fields]: [‘article_name’, ‘image’, ‘author’, ‘description’, ‘isbn’, ‘status’, ‘publisher’]
13:48:18 web.1 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Now, My question is what are these two fields (“Route” and “Is Published Field”) and what should be the values?