C'est exactement ça, c'est pas vraiment plus "light" c'est surtout plus "DRY"
(le concept de pas recoder deux fois la même chose) vu que tu ne rédéfinit pas
un champ qui l'a déjà été automatiquement par ton ModelForm.
--
Cordialement,
David THENON.
Le jeudi 24 mai 2012 19:01:59, Gabriel MACHADO a écrit :
> Donc la deuxième méthode serait plus light car je ne redéfinis pas
> entièrement le champ (field), mais juste son queryset. C'est bien ça ?
>
>
> Le code suivant marche aussi (pas encore testé avec -ordering):
>
>
> class DealForm(ModelForm):
> def __init__(self, *args, **kwargs):
> super(DealForm, self).__init__(*args, **kwargs)
> self.fields['peer'].queryset = Peer.objects.all().order_by('name')
> self.fields['category'].queryset =
> Category.objects.all().order_by('title')
> class Meta:
> model = Deal
> _______________________________________________
> django mailing list
> [email protected]
> http://lists.afpy.org/mailman/listinfo/django
_______________________________________________
django mailing list
[email protected]
http://lists.afpy.org/mailman/listinfo/django