- 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"
- This shouldn't be happening because I just want to edit one field in the form.
- #models excerpt
- class Finhall(models.Model):
- user=models.ForeignKey(User)
- name=models.CharField(max_length=250, unique=True)
- address=models.CharField(max_length=200)
- city=models.CharField(max_length=200)
- def __unicode__(self):
- return self.name
- #editing form views.py
- @login_required
- def edit_finhall(request,finhall_id=None,slug=None):
- if id:
- post=get_object_or_404(Finhall,id=finhall_id,slug=slug)
- initial={'0':{'who':post.who,'name':post.name,'main_view':post.main_view,
- },
- '1':{'price':post.price,'details':post.details,
- },
- }
- if post.user !=request.user:
- return HttpResponseForbidden()
- else:
- initial={'0':{'who':post.who,'name':post.name,'main_view':post.main_view,
- },
- '1':{'price':post.price,'details':post.details,
- },
- }
- form=FindventWizard.as_view([FinhallForm1, FinhallForm2],initial_dict=initial)
- 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+unsubscribe@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.
No comments:
Post a Comment