こんにちは、石黒と申します。

大いなる勘違いをしていました。原因はビューのほうにあったようです。

ビューでフォームからインスタンスを新しいインスタンスとして取得しているコードを
記述していました。
下記のように変更したところユニーク制約に関するエラーは報告されず、正常に更新できました。

Djangoを最近勉強しはじめたので、まだ勘違いしているかもしれませんが...。

def company_detail(request, id):
   template = loader.get_template(u'organization/
organization_company_form.html')
   context = RequestContext(request, None, [base_processor,])
   company = get_object_or_404(Company, pk = id)
   if request.method == 'POST':
      form = CompanyForm(request.POST, instance = company)
      if form.is_valid():
         company = form.save()
         redirect_url = '/django_site/organization/company/'
         return HttpResponseRedirect(redirect_url)
   else:
      form = CompanyForm(instance = company)
   context['form'] = form
   context['verbose_name'] =
ContentType.objects.get_for_model(Company).name
   return HttpResponse(template.render(context))

このような間違いをおこさないようにジェネリックビューを使用したほうがよさそうです。

--~--~---------~--~----~------------~-------~--~----~
-----------------                       http://www.djangoproject.jp/            
             -----------------
You received this message because you are subscribed to the Google Groups 
"django-ja" group.
To post to this group, send email to django-ja@googlegroups.com
To unsubscribe from this group, send email to 
[メールアドレス保護]
For more options, visit this group at http://groups.google.com/group/django-ja
-~----------~----~----~----~------~----~------~--~---

メールによる返信