X-Git-Url: http://git.ithinksw.org/~kgodey/maayanwich.git/blobdiff_plain/95a7feb5f0f608cd7db7215b09046000c1a01af2..d70badd3a28a3b951b32e4cf36562ec3cfd9dd41:/views.py diff --git a/views.py b/views.py index 2b92417..cb8e7e6 100644 --- a/views.py +++ b/views.py @@ -11,10 +11,6 @@ import datetime def add_sandwich(request): - if Sandwich.objects.count() > 5: - sandwiches = Sandwich.objects.order_by('date_made')[:5] - else: - sandwiches = Sandwich.objects.order_by('date_made') if request.method == 'POST': # If the form has been submitted... form = SandwichForm(request.POST, request.FILES) # A form bound to the POST data if form.is_valid(): # All validation rules pass @@ -25,6 +21,11 @@ def add_sandwich(request): else: form = SandwichForm() # An unbound form + if Sandwich.objects.count() > 5: + sandwiches = Sandwich.objects.order_by('date_made')[:5] + else: + sandwiches = Sandwich.objects.order_by('date_made') + return render_to_response('sandwich.html', {'sform': form, 'sandwiches': sandwiches,})