Hi there.  I'm a newbie at Python but have lots of experience with PHP and
MVC frameworks in general.  The question I have is on the proper Django way
to solve a problem.
I want to create a form where you can enter multiple teams and multiple
dates in order to find out where and when they are playing a baseball game.
 So, in the abstract you'd have stuff like this:

Team 1 <input name='team[]'> <input name='date[]'>
Team 2 <input name='team[]'> <input name='date[]'>
Team 3 <input name='team[]'> <input name='date[]'>

So, my question becomes this:

1) how do I get Django to generate those form elements for me so I don't
have to do it by hand
2) how do I get Django to process those values when they come in.

I've been using the Django Book site and the Django Project site to help me,
and they've been great but I can't find much about how to solve this
problem.  Maybe my Google fu is not strong enough.

I'm already creating my own Form object

from django import newforms as forms
    class SearchForm(forms.Form) :
       team = forms.CharField()
       gameDate = forms.DateTimeField()

and already understand to a certain extent how to process the incoming POST
data

def search_results(request):
if request.method == 'POST':
form = SearchForm(request.POST)
 if form.is_valid():
team = form.cleaned_data['team']
gameDate = form.cleaned_data['gameDate']
team = Team.objects.get(name=team)
games = Game.objects.order_by('game_date').filter(home_team=team,
game_date=gameDate) | Game.objects.order_by('game_date').filter(away_team=team,
game_date=gameDate)
 if games.count <= 30:
showResults = True
else:
showResults = False
 else:
games = 'Hoopa'
 return render_to_response('search/results.html', {'games': games,
'showResults': showResults})
else:
return HttpResponseRedirect('index/index.html')


Any help would be greatly appreciated. Tips on doing things the Django way,
or even just the Python way are good as well.  I'm trying hard to not write
PHP-style code in Python.  :)

-- 
Chris Hartjes

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to