It tells me

Column 'customer_id' cannot be null")   because of the foreign key,
customer_id is the id of the customer, that the Issues field is linked
to. How do i auto fill in this field?

On Dec 20, 10:17 pm, Empty <[EMAIL PROTECTED]> wrote:
> This is not a very secure thing to do.  But if you must, then just use
> initial to set the value.
>
> Michael Trier
> blog.michaeltrier.com
>
> On Dec 20, 2007 2:32 PM, mike <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello, I am looking for a way to auto-populate a newforms field, I
> > would like to have the input hidden, and be auto-populated with the
> > name field of the Customer class the Issue class is a foreign key to
> > the Customer class can anyone point me in the right direction, any
> > help would be appreciated, should I use base_fields or is there a
> > better way?
>
> > def add_edit_customer(request, id=None):
> >    if id is None:
> >         CustomerEntryForm = forms.form_for_model(Customer)
> >    else:
> >         IssueEntryForm = forms.form_for_model(Issue)
> >         entry = get_object_or_404(Customer, pk=id)
> >         issues = Issue.objects.filter(name=entry.name)
> >         CustomerEntryForm = forms.form_for_instance(entry)
> >         cust1 = Customer.objects.get(pk=id)
> >         issues = Issue.objects.filter(customer=cust1)
> >         IssueEntryForm.base_fields['customer'].widget =
> > widgets.HiddenInput()
> >         IssueEntryForm.base_fields['customer'] = cust1.name
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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