我一直在谷歌App Engine的使用時,Django模板收到此錯誤:谷歌App Engine的Python的Django的TemplateSyntaxError:無效的塊標籤: 'ENDIF'
TemplateSyntaxError:無效的塊標籤: 'ENDIF'
Python代碼:
class SuperAdmin(webapp.RequestHandler):
def get(self):
#set the user object
user = users.get_current_user()
# See if user is logged in
if user: # signed in already
#Create Logout URL
logoutUrl = users.create_logout_url(self.request.uri)
template_values['logoutUrl'] = logoutUrl
#is this user a super admin
isSuperAdmin = acl_authentication.AuthenticateUserViaAcl().isUserSuperAdmin(user.email(), user.user_id())
template_values['isSuperAdmin'] = isSuperAdmin
#Use our auth object to see if the user is allowed on this page
if acl_authentication.AuthenticateUserViaAcl().IsUserPermitted(user.user_id(), user.email(), '0', '0', 50): #User is allowed
self.response.out.write("This user is in the acl db and a super admin<br/>")
#Add action1 to template_values
template_values['action1'] = self.request.get('action1')
#Write the Header
path = os.path.join(os.path.dirname(__file__), 'adminHeader.html')
self.response.out.write(template.render(path, template_values))
#Write the Login Page
path = os.path.join(os.path.dirname(__file__), 'SuperAdmin.html')
self.response.out.write(template.render(path, template_values))
#Write the Header
path = os.path.join(os.path.dirname(__file__), 'adminFooter.html')
self.response.out.write(template.render(path, template_values))
else: #User is not allowed
#Log to DB that we hit access denied page
acl_authentication.AuthenticateUserViaAcl().LogToDbAccessDeniedHit(user.user_id(), user.email(), self.request.url)
#Redirect to Access Denied Page
self.redirect("/AccessDeniedPage")
else: #User is not logged in
self.redirect("/LoginPage?destUrl=" + self.request.url)
html的模板代碼
<!-- Begin If action1==manage_companies -->
{% if action1 == "manage_companies" % }
<tr>
<td>Manage Companies</td>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
{% endif %}
<!-- /End If action1==manage_companies -->
我ñ不熟悉Django,所以我迷失在這裏。由於
好像有在「%」和「}」之間的空間你關閉模板中的{%if ...'標記。它應該是'%}'而不是'%}'。 –