Hi, Yes, because i use appengine, so django model not supported.
Btw i fixed the problem , by using {{ postForm.category }} instead, and put the css class by define category = forms.CharField(widget = forms.TextInput(attrs={'class':'somecssclass'}) instead of wrote it in html. Thanks. On Oct 28, 12:26 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Oct 27, 3:25 pm, Hudar <hudars...@gmail.com> wrote: > > > > > Hi, > > > Just wondering, how we could show initial value on the edit form. Let > > say we have code like this to retrive the data ; > > > if request.method == 'GET': > > post = models.Post.get_by_key_name(key_name) > > editPostForm = postform.PostForm(initial={ > > 'title': post.title, > > 'body': post.body, > > 'category': post.category, > > 'tags': ' '.join(post.tags)}) > > > return render_to_response('admin/newpost.html', { > > 'postForm':editPostForm, > > 'action':post.get_edit_url(),}) > > > but when i code the form like this : > > <input id="id_category" class="textInput" type="text" size="50" > > name="category" max_length="30" > > value="{% if postForm.category.data %}{{ postForm.category.data }}{% > > endif %}"> > > > it doesnt show up the initial category in the textfield. Please help, > > thanks > > You probably need to use post.category.id in your initial dictionary. > > However, you would be better off using a ModelForm, and passing > 'instance' rather than 'initial'. > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.