Skip to content

Instantly share code, notes, and snippets.

@byroot
Created March 2, 2011 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save byroot/851943 to your computer and use it in GitHub Desktop.
Save byroot/851943 to your computer and use it in GitHub Desktop.
def formation(request):
if request.method == 'POST':
form = ConsultFormationForm(request.POST)
if form.is_valid():
theme_choisi = form.cleaned_data['theme']
duree_min_choisie = form.cleaned_data['duree_min']
duree_max_choisie = form.cleaned_data['duree_max']
if theme_choisi is not None:
if duree_min_choisie != 'no' and duree_max_choisie !='no':
list_formations = Formation.objects.filter(theme__libelle__exact=theme_choisi,duree__gt=duree_min_choisie, duree__lt=duree_max_choisie)
else:
list_formations = Formation.objects.filter(theme__libelle__exact=theme_choisi)
else:
list_formations = Formation.objects.all()
else:
form = ConsultFormationForm()
return render_to_response('catalogue/index.html', {'form': form},context_instance = RequestContext(request))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment