Seems that I'll have to test better and then maybe com back!!.... Sorry! On 1 fév, 20:34, "Sebastien Armand [Pink]" <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I'm not used to contribute to free softwares and don't really know how to! > But I've had to change a part of Django for personnal use: I wanted a model > field like CharField(choices=...) to become a form.ChoiceField(choices=...) > when using the form_for_model() function. > > I changed the models.Charfield() formfield method from > > def formfield(self, initial=None): > return forms.CharField(max_length=self.maxlength, required=not > self.blank, label=capfirst(self.verbose_name), initial=initial) > > to > > def formfield(self, initial=None): > if self.choices != None: > return forms.ChoiceField(required=not self.blank, > label=capfirst(self.verbose_name), initial=initial,choices=self.choices) > return forms.CharField(max_length=self.maxlength, required=not > self.blank, label=capfirst(self.verbose_name), initial=initial) > > And this does the job. > > I don't know if it's worth submitting and even if it is, don't know how to!! > > Seb
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---
