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

  • SEARCH
  • Home
  • 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 6757887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:42:32+00:00 2026-05-26T13:42:32+00:00

I defined one custom tag {% get_user user_id %} which catch user’s id and

  • 0

I defined one custom tag {% get_user user_id %} which catch user’s id and return user object through variable user_obj: {{ user_obj.email }}, {{ user_obj.name }}, {{ user_obj.photo.url }} and so on.

And it works fine. Next I defined tag {% get_user_items user %} which get user object and returns user’s photo url through variable user_photo: {{ user_photo }}.

I want to make interaction between this 2 custom tags. It means smth like that:

{% load user_tags %}
{% get_user 1 %}
{{ user_obj }} // returns unicode string as expected
{% get_user_items user_obj %}
{{ user_photo }}

As I understand tag ‘get_user_items’ must get a user object through variable user_obj, but no – it gets from variable user_obj the usual string ‘user_obj’, not object!!!

How to fix this? What am I doing wrong??? How can I transmit value from variable {{ user_obj }} to tag {% get_user_items %} directly?

Thanks for your answers in advance!!!

  • 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-26T13:42:33+00:00Added an answer on May 26, 2026 at 1:42 pm

    You have to resolve the string as a variable using the context. See discussion on passing template variables to tags in the Django docs

    class FormatTimeNode(template.Node):
        def __init__(self, date_to_be_formatted, format_string):
            self.date_to_be_formatted = template.Variable(date_to_be_formatted)
            self.format_string = format_string
    
        def render(self, context):
            try:
                actual_date = self.date_to_be_formatted.resolve(context)
                return actual_date.strftime(self.format_string)
            except template.VariableDoesNotExist:
                return ''
    

    This is the example from the docs. You must first mark the value as a variable using template.Variable. The argument for that is the argument that holds the variable name. In the example, that’s date_to_be_formatted. This is saved as an instance variable on the node so it’s available later in the render method.

    Then, in the render method, you attempt to resolve the Variable from the context (render has access to the context, which is why it’s done here). This is done by calling resolve on the instance variable you created in the __init__ method and passing it the context as it’s argument. The variable could potentially fail to resolve, which is why it needs to be in a try...except block.

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

Sidebar

Related Questions

How does one go about sorting a vector containing custom (i.e. user defined) objects.
hi i defined one class to create cookie by received parameter's from user. when
I defined one of my custom method in PostsController as follows:- class PostsController <
I'm having trouble passing a variable defined in one class instance to another class
I have a small custom object defined as: public class TimeSeriesDefinition { public int
I have one problem to work with NSMutableData . I defined one NSMutableData *receivedData
I have the following layout defined for one of my Activities: <?xml version=1.0 encoding=utf-8?>
If I have the core of a class defined in one file as public
I'm getting a NoMethodError when trying to access a method defined in one of
I'm attempting to pass a pointer to a function that is defined in one

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.