Hai, I am trying to learn django on my own. I have created a small project of a shop. I am able to insert items but when i try to fetch items for updating / deleting, the form is not populated . only the primary key is shown. def updatedeleteitem(request): item=None updatedeleteform=None if request.method=='POST': keysearchform=KeysearchForm(request.POST) if keysearchform.is_valid(): itemcode=keysearchform.cleaned_data['itemcode'] try: item=Item.objects.get(itemcode=itemcode) updatedeleteform=UpdatedeleteForm(request.POST, instance=item) if updatedeleteform.is_valid(): updatedeleteform.save() transaction.commit() return redirect('itemlist') except Item.DoesNotExist: pass else: keysearchform=KeysearchForm() return render(request,'updatedeleteitem.html', {'keysearchform' : keysearchform, 'updatedeleteform' : updatedeleteform, 'item' : item}) ___________________________________________________________________ class UpdatedeleteForm(forms.ModelForm): class Meta: model=Item fields=['itemcode', 'itemname', 'unitpr', 'qty'] class KeysearchForm(forms.Form): itemcode=forms.CharField(label='item code', max_length=5)
These are the view & Forms I am using. Please help. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6decf54f-8187-4ff0-a8ec-2fb137120e35n%40googlegroups.com.