Hi,

When i edit a records  none of the modelchoicefields are getting selected 
using form edit form instance.

I have gone though below blog, but confusing

http://blog.brendel.com/2009/07/setting-initial-value-for-djangos.html


*view.py* :

def EditTable(request, get_id):
  detail_data = shortcuts.get_object_or_404(models.TestTable, id=get_id)
  if request.method == 'POST':
    form = forms.EditForm(
        request, data=request.POST, instance=detail_data)
    if form_is_valid():
        form.save()
  else:
    form  =  forms.EditForm(instance=detail_data)
 return form

*form.py*

class EditForm(forms.ModelForm):
  activity = forms.TypedChoiceField(choices=choice.Activity_CHOICES)
  def __init__(self,  *args, **kwargs):
    super(EditForm, self).__init__(*args, **kwargs)
    self.fields['b_name'] = forms.ModelChoiceField(
        queryset=models.CreateDb.objects.filter( list_p='English', 
status='A'),
    self.fields['type'] = forms.ModelChoiceField(
        queryset=models.CreateType.objects.filter( list_T='Grammer', 
status='A'),
    
I any help really appreciate. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/eGVYTVF2bU04YmNK.
To post to this group, send email to django-users@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.

Reply via email to