Re: dynamic value of a ModelChoiceField

2008-06-24 Thread [EMAIL PROTECTED]
thanks v sergeyev. the above suggestion worked.. the initial dictionary was expecting the "recipe.cooking_method.id" value..wonder why just the "recipe.cooking_method" wouldnt work ? thnx, -p On Jun 24, 10:13 am, "V.Sergeyev" <[EMAIL PROTECTED]> wrote: > You need to pass initial dictionary

Re: dynamic value of a ModelChoiceField

2008-06-24 Thread V.Sergeyev
You need to pass initial dictionary to RecipeForm() constructor. ... def edit_recipe(request,recipe_id): if request.method == "POST": yadda yadda else: recipe = Recipe.objects.get(id=recipe_id) recipeform = RecipeForm(initial={"cooking_method": recipe.cooking_method.id})

Re: dynamic value of a ModelChoiceField

2008-06-24 Thread Arien
On Mon, Jun 23, 2008 at 10:34 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > here's my model: > > class Recipe(modesl.Model): > > recipetitle = models.CharField() > cooking_method = models.ForeignKey(CookingMethod) > > class CookingMethod(models.Model): > > cookmethodname =

Re: dynamic value of a ModelChoiceField

2008-06-23 Thread [EMAIL PROTECTED]
thanks rishabh, i tried that -- it doesnt display the 'selected' cooking method for the recipe. shows the value corresponding to empty_label. thnx, -p On Jun 24, 12:23 am, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote: > You're probably looking >

Re: dynamic value of a ModelChoiceField

2008-06-23 Thread Rishabh Manocha
You're probably looking for http://www.djangoproject.com/documentation/newforms/#initial Best, Rishabh On Tue, Jun 24, 2008 at 9:04 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I probably need to be more specific.. > > here's my model: > > class Recipe(modesl.Model): > > recipetitle

Re: dynamic value of a ModelChoiceField

2008-06-23 Thread [EMAIL PROTECTED]
I probably need to be more specific.. here's my model: class Recipe(modesl.Model): recipetitle = models.CharField() cooking_method = models.ForeignKey(CookingMethod) class CookingMethod(models.Model): cookmethodname = models.CharField() forms.py class RecipeForm(forms.Form):

dynamic value of a ModelChoiceField

2008-06-22 Thread [EMAIL PROTECTED]
In a form, I have a field defined as ModelChoiceField class myForm(forms.Form) myfield = forms.ModelChoiceField(MyClass.objects.all()) myfield2 = forms.CharField() My problem is that I cant seem to dynamically set the value that the user selected for this field. When ever, user edits the