Hi,

I have a model where different users should have different
possibilities to edit, i.e. admin should be able to edit everything,
but users should only be able to edit certain fields.

My problem is that the user form doesn't validate when submitting
update as a user. But I get the error that the fields are missing even
though I can see them redisplayed.

I am looking at this tutorial:
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form
And I don't get what is different in my example since I pass "instance
= c" which contains the missing fields.

def update_contract(request,c):
        if request.user.has_perm("contracts.is_admin") or
request.user.has_perm("contracts.is_internal"):
            contract_form = ContractForm(request.POST, instance = c)
        elif
request.user.has_perm("contracts.is_external"):
              contract_form = ContractFormExternal(request.POST,
instance = c)
        if contract_form.is_valid():
            contract_form.save()
            return view_contract_details(request, c.pk, True)
        else:
            return render_to_response('contracts/
view_contract_details.html', {
                'info_message' : 'Please correct the data in the
form',
                'contract_form': contract_form,
                'contract_id' : c.pk,
            },context_instance=RequestContext(request))


Anyone can hint as to where it goes wrong or a hint to how to better
accomplish this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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