thanks Carl, that was extremely clear, step by step. took me a little bit to get the self.fields, since I was trying to override directly as ratiooo.choices. and I move the django.setup() to the top of the file after the imports (meantime). not sure what it does, I know that just need to be call before any query if not they don't work =(
class FormDishes(forms.Form): your_email = forms.EmailField(initial="a...@b.com") ratiooo = forms.ChoiceField(choices="", widget=forms.RadioSelect(), initial=1) def __init__(self, *args, **kwargs): self.restaurant_id = kwargs.pop("restaurant_id") super(FormDishes, self).__init__(*args, **kwargs) self.options = self.make_choices() self.fields["ratiooo"].choices=self.options def make_choices(self): all = Dish.objects.filter(restaurant_id=self.restaurant_id) options_ratio = [] for i in all: options_ratio.append((i.id, i.name)) return options_ratio -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/816954de-4e6f-411b-bafc-701a8a708227%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.