What is "Route" and "Is Published" field in "DocType > DocType object > Settings > Web View"

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.

  1. Enable Has Web View and Allow Guest to View
  2. Enter articles in the Route field
  3. Add fields named Route and Published in the fields table
  4. 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?

You have to look at the core functionality and check that code.

Hi @NCP,

I am very new to frappe. Could you please provide me with more details? It would be a great help for me.

As a new user, I was not allowed to post a picture. So, here it is, what I am talking about.

Please review the doctype provided in the screenshot, and check the field names for ‘route’ and ‘Is Published’. Set these fields accordingly.

Then reload the page using Ctrl+Shift+R and verify the changes.

Route - you can specify the url in which you can see the article details. Say example in my case, I uploaded an article “Ammachi’s glasses”. Then in the route field I specified as books/ammachis_glasses as that will become the URL to see the article in webview.

Published - It is a check box. If the box is checked then the article is published in the route URL given. Otherwise you won’t have a website URL to see that article and will just have record of that article alone. Hope it helps you @mayank_gupta

Thanks.