On Nov 24, 2012, at 2:41 PM, Sergiy Khohlov <skhoh...@gmail.com> wrote:

> I would like to clarify:
> 
> 1) you dont need to add client id to the form
> (this value is already  set in your view)
> 
> 2) If you dont know how to  save address let ask
> Of course please add your code. I can not hack your PC and understand
> your problem.
> 
> thanks, Serge
> 2012/11/24 Lee Hinde <leehi...@gmail.com>:
>> nt to seed the client id programmatically without presenting a form
>>> field to enter what's a known value
> 
> -- 


Thanks for sticking with this.

class AddressForm(ModelForm):
    def __init__(self, *args, **kwargs):
        super(AddressForm, self).__init__(*args, **kwargs)

        self.fields['city'].widget.attrs["class"] = 'capme'
        self.fields['zip'].widget.attrs["class"] = 'zipcode'
        self.fields['state'].widget.attrs["class"] = 'input-mini upper_case'

    class Meta:
        model = Address
        fields = 
('street_one','street_two','city','state','zip','response_type')
        exclude = ('client',)


class AddressNew(CreateView):
    model = Address
    template_name = 'letters/address.html'
    form_class = AddressForm
    context_object_name = 'myfields'

    def get(self, request, *args, **kwargs):
        set_current_page(request, "", "active", "", "")
        return super(AddressNew, self).get(request, *args, **kwargs)

    def get_context_data(self, **kwargs):
        context = super(AddressNew, self).get_context_data(**kwargs)
        context['client_data'] = get_object_or_404(Client,pk=self.kwargs["pk"])
        return context


Then, in the template I'm putting client_data.id into a hidden field to be 
returned when the form is saved.


-- 
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 
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