I have an attendee list for an event. Attendees objects are keyed to Profile Objects.
Within the view I’m trying to append 3 lists to make up attendee_list.
Models.py
class Attendee(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
profile = models.ForeignKey(Profile)
event = models.ForeignKey(Event)
verified = models.BooleanField(default=False)
from_user = models.BooleanField(default=False)
view.py
verified_attendees = [va.profile for va in Attendee.objects.filter(event=event, verified=True)]
unverified_attendees = [uva.profile for uva in Attendee.objects.filter(event=event, verified=False, from_user=True)
pending_attendees = [pa.profile for pa in Attendee.objects.filter(event=event, from_user=False, verified=False)]
attendee_list = ????
What I’d like to accomplish(template):
{% for attendee in attendees_list %}
...
Name | Status
--------------------------------------
Jon Doe | Pending
Annie Smith | Verified!
Abraham Snow | Confirm Yes/No?
How can I throw these 3 lists into one, and still check which list they belong to (whether in the view or template)? The reason why I want one list is because I will be sorting attendees alphabetically. Thanks for you suggestions in advance!
Why split in the first place when you could do:
and then:
You can then control what each says at the template level using
{% if verified %}or{% if from_user %}blocks.Alternatively, you can just do:
and refer to
attendee.profile,attendee.verified, andattendee.from_userdirectly in the template.