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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:48:44+00:00 2026-06-09T13:48:44+00:00

There’s a registration button that creates an Attendee for that specific event.(that works). However,

  • 0

There’s a registration button that creates an Attendee for that specific event.(that works). However, upon clicking ‘Register’, the template recognizes 'is_attending'= True(Registered!) for every Event in upcoming.

View:

def index(request):
    upcoming = Event.objects.filter(date__gte=datetime.now())
    if request.user.is_authenticated():
        profile = Profile.objects.get(user=request.user)
    is_attending = False
    for event in upcoming:
        attendees = [a.profile for a in Attendee.objects.filter(event=event)]
        if profile in attendees:
            is_attending = True

template

{% if is_attending %}
     <a><Registered!</a>
{% else %}
     <form>... registration form ... Register Now...

I guess what’s happening is:

event 1  : Registered!
event 2  : Registered!
event 3  : Registered!

When what I need is :

event 1  : Registered!
event 2  : Register Now
event 3  : Register Now

I’m not quite sure why this isn’t working for me? How do I loop through to return is_attending for only those who have registered within upcoming events?

Models:

class Attendee(models.Model):
    event = models.ForeignKey(Event)
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    profile = generic.GenericForeignKey('content_type', 'object_id')
  • 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-09T13:48:45+00:00Added an answer on June 9, 2026 at 1:48 pm

    You’re over-writing the value of is_attending every time you go through the for loop; your template sees the (single) value of is_attending as set by whether the last event in upcoming is being attended by request.user.

    To get the desired behaviour, one piece of is_attending info for each Event. I think the easiest way to do this is with a custom template tag:

    @register.simple_tag(takes_context=True)
    def user_is_attending(context, event):
        if type(event) != Event:
            raise template.TemplateSyntaxError("Must provide event")
        request = context['request']
        if event.attendee_set.filter(profile__user=request.user).exists():
            return 'attending'
        else:
            return 'not attending'
    

    Then, while you’re looping over your events in the template:

    {% user_is_attending event %}
    

    You could also consider using an assignment tag or an inclusion tag depending on your needs.

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

Sidebar

Related Questions

There is a moment in my app, that I need to force to show
There is a column that exists in 2 tables. In table 1, this column
There are a lot of blogs saying that a hasOwnProperty check should be used
There is a website called Gild.com that has different coding puzzles/challenges for users to
There is a shared folder in my D drive as works ( D:\works ).
There is a div (form) which opens on the click of a button. There
There is no doubt that MonoTouch is one of the great cross-compiler(s). Similarly, SenchaTouch
There are some stdlib functions that throw errors on invalid input. For example: Prelude>
There is my code that I want to alert test once when mousemove ,
There is a class that's a fully fledged UIViewController and when that page loads

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.