Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 786509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:03:11+00:00 2026-05-14T21:03:11+00:00

the method is: def printa(x): return x the response is: self.response.out.write(template.render(path, {‘printa’:printa})) the html

  • 0

the method is:

def printa(x):
    return x

the response is:

self.response.out.write(template.render(path, {'printa':printa}))

the html is:

{{ printa 'sss'}}

I want to show ‘sss’ in my page ,

so how to do this ,

updated

I create a templatetags folder, and 2 py file:

templatetags 
     |--------__init__.py
     |--------tags.py

in tags.py is:

#from django import template
from google.appengine.ext.webapp import template

register = template.Library()

def printa():
    return 'ssss'
register.simple_tag(printa)

the html is:

{% load tags%}
{% printa %}

but it show error, and the error is:

TemplateSyntaxError: 'tags' is not a valid tag library: Could not load template library from django.templatetags.tags, No module named tags

why?

what’s wrong?

answer is:

tags.py:

from google.appengine.ext import webapp
register = webapp.template.create_template_register()

@register.filter
def printa(value,y):
return 'url:%s' % y

@register.tag
def printb(x,y):
return str(x.__dict__) +'dddddddddddddddddddddddddddddddd'+ str(y.__dict__)
#return x
#register.tag('printb',do_pagednav)

and then in html (a is a variable i send to the template):

{{a|printa:"dwqdq"}}

{% printb %}

woring:

don’t use load:

{% load sometags %}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:03:12+00:00Added an answer on May 14, 2026 at 9:03 pm

    Using the default webapp template system (which is actually Django 0.96), you can’t do this. You’re expected to put the program logic in the program files, not in your templates, so you can’t pass arguments to your variables.

    You don’t say what you’re actually trying to do, though; I assume you don’t literally want to print something, since you can just put that something in the template without a function and it prints. For whatever you’re actually trying to do, registering a custom filter might be what you’re looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a controller method like: def show @model = Model.find(params[:id]) respond_to do |format| format.html
If you have a controller method like so: @expose(json) def artists(self, action=view,artist_id=None): artists=session.query(model.Artist).all() return
module Superpower # instance method def turn_invisible ... end # module method def Superpower.turn_into_toad
So I've got a Ruby method like this: def something(variable, &block) .... end And
my ruby (on rails) class looks like: class Foo def self.method1 someAction end def
Given that a function a_method has been defined like def a_method(arg1, arg2): pass Starting
Let's say I have the following ruby code : def use_object(object) puts object.some_method end
Say I have the following methods: def methodA(arg, **kwargs): pass def methodB(arg, *args, **kwargs):
Method chaining is the only way I know to build fluent interfaces. Here's an
What method do you use when you want to get performance data about specific

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.