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
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})
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 =
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
>
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
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):
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
7 matches
Mail list logo