Is there a way I can validate form data after doing
form.save(commit=False)?

I am using (commit=False) because I want to set the model ForeignKey
after the data has been posted, for example here is my view:


def domain_dnsrecords(request, domain_id):

        DNSRecordForm = forms.form_for_model(DNSRecord,
fields=('name','type','data','aux','ttl'))

        if request.method == 'POST':

                form = DNSRecordForm(request.POST)

                dnsrecord = form.save(commit=False)

                dnsrecord.domain_id = domain_id

                dnsrecord.save()

                return HttpResponseRedirect("/hosting/domain/dnsrecords/%i/" %
int(domain_id))

        else:
                form = DNSRecordForm()

        dnsrecords = DNSRecord.objects.filter(domain=domain_id)

        return render_to_response('hosting/dnsrecords.html', {'dnsrecords':
dnsrecords, 'dnsrecordform': form})


After setting the foreign key (domain_id) I would like to check the
complete data to see if it is valid.

Any ideas?

Paddy


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to