You can check the code properly here: http://pastebin.com/1Ygq9RZs



   1. I have two seperate forms and I used Django ModelForm wizard to 
   create the form. I can create and save the form.Also I created a 
   seperate view for editing of the form, but When I wanted to edit the 
   same form, a field called'name' with 'Unique=True' in the models is always 
   popping out validation error "name already exist"
   2.  
   3. This shouldn't be happening because I just want to edit one field in 
   the form.
   4. #models excerpt
   5. class Finhall(models.Model):
   6.    user=models.ForeignKey(User)
   7.    name=models.CharField(max_length=250, unique=True)
   8.    address=models.CharField(max_length=200)
   9.    city=models.CharField(max_length=200)
   10.    
   11.    def __unicode__(self):
   12.          return self.name
   13.  
   14. #editing form views.py
   15. @login_required
   16. def edit_finhall(request,finhall_id=None,slug=None):
   17.    if id:
   18.        post=get_object_or_404(Finhall,id=finhall_id,slug=slug)
   19.        initial={'0':{'who':post.who,'name':post.name,'main_view
   ':post.main_view,
   20.                      
   21.                     },
   22.                 '1':{'price':post.price,'details':post.details,
   23.                      },
   24.                 }
   25.        if post.user !=request.user:
   26.            return HttpResponseForbidden()
   27.    else:
   28.      initial={'0':{'who':post.who,'name':post.name,'main_view
   ':post.main_view,
   29.                      
   30.                     },
   31.                 '1':{'price':post.price,'details':post.details,
   32.                      },
   33.                 }
   34.        
   35.    form=FindventWizard.as_view([FinhallForm1, 
   FinhallForm2],initial_dict=initial)
   36.    return form(context=RequestContext(request), request=request)
   

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to