Hi --

I'm building a scheduling app for my burning man camp.  There are seven 
days (Mon-Sun), and each day has two meals, and people can sign up for the 
available shifts. 

Here's my table:


class mealShifts(models.Model):
Sunday = "Sunday"
Monday = "Monday"
Tuesday = "Tuesday"
Wednesday = "Wednesday"
Thursday = "Thursday"
Friday = "Friday"
Days = (
(Sunday, "Sunday"),
(Monday, "Monday"),
(Tuesday, "Tuesday"),
(Wednesday, "Wednesday"),
(Thursday, "Thursday"),
(Friday, "Friday"),
)
Breakfast = "Breakfast"
Dinner = "Dinner"
Meals = (
(Breakfast, "Breakfast"),
(Dinner, "Dinner"),
)
Chef = "Chef"
Sous_Chef = "Sous-Chef"
KP ="KP"
Shifts = (
(Chef, "Chef"),
(Sous_Chef, "Sous_Chef"),
(KP, "KP"),
)
assigned = models.BooleanField(default=False)
day = models.CharField(max_length = 10, choices=Days, default=Sunday)
meal = models.CharField(max_length = 10, choices=Meals, default=Dinner)
shift = models.CharField(max_length = 10, choices=Shifts, default=KP)
camper = models.OneToOneField(User)

class Meta:
unique_together = ("day", "meal", "shift")

def __str__(self):
return '%s %s %s %s'%(self.day, self.meal, self.shift, self.camper)



And my views function:

def signup(request):

shifts = mealShifts.objects.all()

username = None

if not request.user.is_authenticated():

return 

if request.method == 'POST':

form = MealForm(request.POST)

if form.is_valid():

shift = form.save(commit=False)

shift.camper = request.user

shift.save()

return redirect('signup')


else:

form = MealForm()

return render_to_response('signup.html', 

RequestContext(request, {'form':form,'shifts':shifts, 
'username':username},))


 
And here's the part of the template that displays the shifts:


<h2>Shifts</h2>

<div id="datatable">

<ul>

{% for shift in shifts %}

<li>{{shift.camper}} {{shift.day}} {{ shift.meal }} </li>

{% endfor %}

</ul>

</div>

</div>



How can I display the data in the template so the shifts are sorted by day, 
and then by meal?

Thank you,

Becka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3f3144db-8efc-4630-8911-7dbb25da488d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to