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 8462907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:18:34+00:00 2026-06-10T14:18:34+00:00

Performing a check to see whether or not a user is attending or not.

  • 0

Performing a check to see whether or not a user is attending or not. How do I pass the context variable is_attending to the template without getting a syntax error on 'is_attending': context['is_attending']? The check is basically for styling divs and whatnot. What am I doing wrong?

template:

{% for event in upcoming %}
    {% registration %}

    {% if is_attending %}
         Registered!
    {% else %}
          Register button
    {% endif %}

    yadda yadda divs...
{% endfor %} 

filters.py

@register.inclusion_tag('events/list.html', takes_context=True)
def registration(context, event):
    request = context['request']
    profile = Profile.objects.get(user=request.user)
    attendees = [a.profile for a in Attendee.objects.filter(event=event)]
    if profile in attendees:
        'is_attending': context['is_attending']
        return is_attending
    else:
        return ''

Thank you!

  • 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-06-10T14:18:36+00:00Added an answer on June 10, 2026 at 2:18 pm

    'is_attending': context['is_attending'] is not valid python. Rather, it looks like a partial dictionary. Since .inclusion_tag() code is supposed to return a dict, perhaps you meant the following instead:

    if profile in attendees:
        return {'is_attending': context['is_attending']}
    else:
        return {'is_attending': ''}
    

    Also note that takes_context means you’ll only take the context as an argument. From the howto on custom tags:

    If you specify takes_context in creating a template tag, the tag will have no required arguments, and the underlying Python function will have one argument — the template context as of when the tag was called.

    Thus your tag should be:

     {% registration %}
    

    and your full method can take the event argument directly from the context:

    @register.inclusion_tag('events/list.html', takes_context=True)
    def registration(context):
        request = context['request']
        event = context['event']
        profile = Profile.objects.get(user=request.user)
        attendees = [a.profile for a in Attendee.objects.filter(event=event)]
        if profile in attendees:
            return {'is_attending': context['is_attending']}
        else:
            return {'is_attending': ''}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to lower my received sequence number for performing FIX certification to check
My extension is simply performing actions on pages based on user clicks; it works
Here is the problem A user of an enterprise web application is performing a
I have a test that requires me to uses Authentication to check to see
I am accustomed to C# not performing overflow checks, as the language spec states
While performing a check if there's a camera present and enabled on my windows
Performing user authentication in Java EE / JSF using j_security_check I tried this solution.
After performing an insert/update/delete, is it necessary to query the database to check if
When performing pre-upgrade check for content manager database from Tridion 2009 SP1 to 2011
When performing many disk operations, does multithreading help, hinder, or make no difference? For

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.